First attempt

Here is an easy and simple way to run a Node-RED flow when Home Assistant starts.

We start in Node-RED with an HTTP node.









Then we edit it to listen to /hastart and choose a name.









This will result in this node which you can insert in your flow and/or create a subflow to use it in multiple flows. Don’t forget to DEPLOY.









Now, in Home Assistant, we create a shell_command and an automation that will run it.

shell_command : ha_start : ' curl http://localhost:1880/hastart' # http://localhost:1880/endpoint/hastart if you're using the Node-RED Community Hass.io Add-on. automation : - alias : homeassistant_start trigger : - platform : homeassistant event : start action : - service : shell_command.ha_start





And that’s it. From now on, every time Home Assistant is started the node is triggered.





A better way

I’ve just found a simpler and better way to do that. All we need is a status node and a switch node.









In this case the status node checks for status changes in a selected node. I selected one of my home assistant “events: state” nodes. The switch node checks if the status node is sending the string “node-red:common.status.connected” in msg.status.text .

Following is the JSON code of the sequence. Do not forget to change the status node configuration according to your environment.