Read the statement by Michael Teeuw here.
Ways to automate shutdown and startup
-
@hesspoint it is very bad to power off without shutdown…
can’t answer the HA question.
but I do one of my systems via MMM-AlexaControl. I just add the Shutdown device to an Alexa routine.
if u had MMM-RemoteControl, you could use it’s API to invoke it’s shutdown command
-
@hesspoint
Your HA might be able to turn on/off switch by schedule. If you set cut power of pi off on 23:00 by HA, just execute shutdown script before through cron on pi… every 22:55? -
I use https://www.amazon.com/gp/product/B087FXLZZH/ as a UPS - it has scriptable shutdown and startup operations - and external leads so you can remotely power on device. something like this might work for you, although, the power consumption is so small, other than the monitor, so I wouldn’t worry about shutting it down, just the monitor.
Also, I’ve decided to change it out, I’m going with a PiJuice UPS instead. need more space.
-
@hesspoint You can shut down the operating system BUT you can’t completely shutdown the power to it. The only way to actually have the pi completely off is to unplug it. By running a shutdown command the led on the pi will still be drawing power and showing you it “isn’t running”.
If you just want to shutdown the operating system/mirror etc and don’t care that the pi still has power… Then, you can do it via the operating system. There is a thing called a cron job which you setup on the crontab. You can set it to run every night at the same time.
Here is a link on the raspberry pi forum about retropi (a different project) that will tell you how setup your cron .
https://www.raspberrypi-spy.co.uk/2018/03/raspberry-pi-retropie-shutdown-button/There are some MagicMirror modules that might help you do the same thing via a web url that points to the pi at your house. You would need a fixed ip address at your house, setup your router to allow the outside world to talk directly to your pi, and setup the module too. I haven’t used one of them.
I think there is an Internet of Things IOT module that could probably work via IFTTT too.
-
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 moduleI 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.
-
@hesspoint Update: There is actually a custom HA integration that is awesome: https://github.com/sindrebroch/ha-magicmirror
So I switched form the REST API to that integration and it is even better