I was hoping to find this in the forums, but no luck so far. I am trying to trigger a sequence in Node-RED when HA starts. In yaml, I used to trigger based on the HA start event, but a few versions ago, that was deprecated (I think), and I moved to the ‘homeassistant’ platform for the trigger:
trigger:
- platform: homeassistant
event: start
Anyone know how to best replicate this in Node-RED? I’ve got all my other automations moved over to Node-RED (and I love it!), and these are the last ones hanging on.
I’m trying to setup something just like this myself but I’ve never done anything with a shell command before. Read the docs and tried to create my own but it doesn’t work. What should my automation and/or shell command look like to create this?
Hi @Greg, could you please elaborate a bit on how to set up the execution of a shell command? I am a bit unsure where the ha_running line you posted is meant to go.
I assume you are using the HA-websocket node. This node can handle all the HA events including Start-Up and Shutdown, as well other useful ones like “new-device” or “new-service”
Alternatively you can use “webhook” commands between NR and other systems like HA or motionEye.
Thanks for the clarfification @Greg! The url http://url:port/hass/running is that something that is usually called during startup? Because it gives me a 404 (unless I am also supposed to change that url to something else)
@xx_Nexus_xx yes, I am using node-red-contrib-home-assistant-websocket which doesnt seem to have a HA-websocket node. Perhaps I can install an additional palette?
Try create a yaml automation that triggers on homeassistant.start event put the action to delay 10-20 seconds then send a custom event. That event should appear and can be easily filtered with the event node.
@xx_Nexus_xx do you know what the actual event_type, topic & payload values are? I have tried sticking a debug node on the all events node, but on a HA restart, it autofreshes my NR (I have it running in Hass.io) so I can’t grab it.
Similar to subzero’s solution above, I have a yaml automation that is triggered on HA start. After a 15 second delay, it turns on an input_boolean. An event state node triggers the flow when the boolean changes.
What is the real motivation of this task? Sometimes it’s not about HA restart but about NodeRed restart instead, for example in order to initialize flow variables. Then Timestamp node is sufficient enough:
Hello! thx for this one! I like it very much. The only issue is that every time I deploy flows, it triggers the entire thing (because NR reconnects to HA). Anyway around that?
thank you, this worked for me and seems like a great solution as it does not require creating an automation in home assistant or messing with shell commands