Turn on red light when homeassistant stops

Hi, as I am sometimes updating/restarting homeassistant when I am not at home (e.g. on a business trip) I’d like to turn on a red light to indicate that HA is down. This would take away some confusion on “User Two” when she is trying to control something but HA is not responding.

I already got it working, that the light turns green and after 2 seconds off again when HA comes back up. Implemented this using Appdaemon like this.

To avoid Appdaemon not catching the homeassistant “shutdown” event I implemented the “Turn light red” automation directly in HA automations but it is not triggering.

Do you guys have any idea what I am missing? Automation works when I trigger it manually.

Automation below, taken from the official documentation:

- alias: Turn on Red Upper Stair Light on Shutdown
  trigger:
    platform: homeassistant
    event: shutdown
  action:
    - service: light.turn_on
      data:
        brightness: 255
        rgb_color: [0, 255, 0]
        entity_id:
        - light.bar_table

I would expect that once HA issues a shutdown, it won’t start any more automations.

Well it used to work for me in the past, though I was using a slightly different format:

  trigger:
    - platform: event
      event_type: homeassistant_stop

I have to say I’ve not had that automation run for a while now and the automation just plays a sound so I’ve not really looked into it, plus I’ve moved to docker and restart my docker when I need to restart HA (which I know if a bit overkill) so I guess the docker will be taken down before HA has the chance to run that automation…

I’m running docker too. I really don’t know why I have thought stopping the docker container would trigger a gracefull shutdown of homeassistant. Or does it?

I don’t know. It used to work when I was not using docker.
I’ve not tried to stop HA from within the container to see if that works, I guess it’s worth a try to potentially take docker out of the equation

If you stop a docker container without first shutting down HA you are essentially pulling the power plug. HA does not get the signal to gracefully shut down.

I suggest you stop HA before stopping the docker container.

If that still doesn’t resolve your issue you could create a toggle that you flip to turn on the light, then restart HA, and have HA turn off the toggle on start.

I am thinking of what the best way forward is here.
I already have a script for restarting the HA container. I am thinking to just include a curl call against HA to turn on the light before restarting the container.
Does anybody have a nice way in mind?

Example:

curl -X POST -H "x-ha-access: YOUR_PASSWORD" \
       -H "Content-Type: application/json" \
       -d '{"entity_id": "switch.christmas_lights"}' \
       http://localhost:8123/api/services/switch/turn_on

taken from:
https://developers.home-assistant.io/docs/en/external_api_rest.html

You might need some extra hardware, but might I suggest a sort of “dead man’s switch”? basically as long as HA is running, it’s sending a signal to something else that is controlling a red light. If that device gets the signal within a reasonable amount of time (say 30 seconds) then it keeps the light off and restarts the timer. As soon as the hardware detects the signal has been lost, it turns on the red light until it starts receiving the signal again.

The light I am using is powered by a MagicHome LED Controller running Tasmota.

I will look and see whether Tasmota has that kind of functionality.

as far as I remember you can access/control your tasmota device via it’s IP address on a web browser. It should be easy to have a script running somewhere that “pings” HA and then turns the red light on when no answer?