Wow, I am blown away by the many responses. Thanks so much guys!
Especially thanks @sdetweil, for pointing me in the right direction with MMM-Remote-Control. That module is absolutely awesome. I now figured out the whole thing, so here it is if anyone likes to know:
First I installed https://github.com/Jopyth/MMM-Remote-Control
You need to use the Rest API requests as in the instructions in the module
I found this for HA: https://community.home-assistant.io/t/controlling-magicmirror2-from-ha/138527
So I need to add each rest api call I want to automate as service in HA. Then I can trigger the service i.e. shutdown in my “leave house” and “night mode” automations.
There are then 2 steps:
- shutting down the Pi via the service/rest api call
- wait a min or two and then kill the power to the pi by switching of the outlet which I can do also in the automation.
When the state change is triggered (e.g. I return home or I start moving in the house in the morning) then the automation just turns the outlet back on and the Pi will boot.