How Do I Watch for HA Start & Shutdown Events in Node-RED

I’m having some trouble figuring out how to watch for “start” and “shutdown” events in Node-RED. I have this working great as a YAML automation but I’m moving everything to Node-RED and having some trouble figuring out what exactly to watch.

Any advice?

TYIA!

Have you added an “Events All” node and put a debug on the output?
Change the setting in the debug to “complete msg object” and you should see everything coming out of HA.

The following services are available under the domain homeassistant

and these are for hassio

This does work with the start events , but there is no event recevied when using shutdown or reboot :frowning:

I ended up using this:

I have another solution that doesn’t require an automation within HA.

[{"id":"f2d88d0.d05847","type":"inject","z":"3907b15f.720dde","name":"HASS Connected?","topic":"","payload":"homeassistant.homeAssistant.isConnected","payloadType":"global","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":280,"wires":[["3be94497.d0409c"]]},{"id":"3be94497.d0409c","type":"rbe","z":"3907b15f.720dde","name":"","func":"rbei","gap":"","start":"","inout":"out","property":"payload","x":310,"y":280,"wires":[["e3ec25ae.6dfb08"]]},{"id":"e3ec25ae.6dfb08","type":"switch","z":"3907b15f.720dde","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":430,"y":280,"wires":[[],[]]}]

There’s a global boolean within the homeassistant object called isConnected. I have a inject node firing the status of that boolean as the payload every second. An RBE node watches for changes (ignoring the initial value). That feeds into a switch node that routes the message based on whether it’s true or false. Then do whatever based on that info. I send a telegram message on both the false and true conditions (Home Assistant Offline/Online). The flow above omits the telegram.

6 Likes

Does anyone knows how to stop an automation from triggering (home or not_home) after a HA restart?

Is your Telegram messaging being handled exclusively within Node-RED? Wouldn’t it have to be since you can’t call the notify service handled by HA when HA is down?

Ya, there’s a couple threads on here about setting up and using Telegram. And I looked at some of the other non-NR Telegram threads for ideas and help too.
Here’s one of the NR Telegram setup threads

Let me know if you need any further help.

Just wanted to come back to say this has worked VERY well for me. Thank you!! Really great solution!

It was working great for me as well, but recently I’ve been getting a lot of duplicates that the rbe node doesn’t seem to be catching. Need to investigate when I have time.