If you’re using node-red-contrib-home-assistant within Node-Red, to create the master/slave connections, it uses REST. In other words, Node-Red communicates the same was as a RESTful sensor (but with the added infrastructure of Node-Red itself).
FWIW, there’s an alternative version called node-red-contrib-home-assistant-websocket, created by @Kermit that addresses some of the shortcomings of using REST (by employing websockets). You can learn more about it here
There are many articles explaining the pros and cons of REST vs MQTT. Here’s one. Basically, if the need is to simply serve as a robust communications channel, MQTT is the better choice.
If you want a basic master/slave system with the least amount of additional infrastructure, then go with @jimpower suggestion and use a RESTful sensor.
If you want to use a better communications technology, install an MQTT Broker and use MQTT Statestream (see my device_tracker example above). Use the include directive to specify only what is needed to be shared with the slave system.
If you also want to transform or manipulate the data sent between master and slave, then install Node-Red and node-red-contrib-home-assistant-websocket. Proceed to create a flow that connects the master to the slave and manipulates the payload. If you do not intend to alter the payload, then Node-Red only serves to provide a visual representation of the master-slave connection.
I use an MQTT Broker and Node-Red to interconnect three Home Automation systems (Premise Home Control, Home Assistant, and openHAB). Home Assistant and openHAB talk directly to the MQTT Broker whereas Premise Home Control relies on a Node-Red flow to convert its data from a TCP channel to MQTT (and vice-versa).
trying to keep the setup as lightweight as possible, for 6 device_trackers, the state_stream should be enough…
but it isn’t very stable. the host seems not to act upon the settings as reliably as desired. have entities configured, and the slave finds these without issue. If and when the Host publishes them. I can spot with MQTT FX that that isn’t always the case, and many other device_trackers are published but not the desired configured ones… ??
which causes frontend errors/log writes on the slave, because I have these entities customized on state, and when no state is received that causes the front-end to be reachable and the system useless.
according to the docs, one should be able to only specify entities, but as I experience now, these aren’t published always. Rebooting now to see if adding the domains: device_tracker will help.
I’ll be back…
Perhaps the Statestream component doesn’t handle things correctly when the entity to be included is also part of the domain to be included? It so, that’s a bug. Maybe specify domainsorentities, for include, but not both?
that’s what I tried, only entities (device_trackers) but it showed many device_trackers, alas not the ones specified…
I now have the domains: device_tracker included, and the same entities and of course it shows all device_trackers, so that’s not very useful…
btw, if I specify device_tracker.device1, (and have it publish the attributes) it creates about 5 or 6 topics for each attribute, and not 1 device_tracker with the attributes connected under it. Could have just called it a sensor for that matter… also not very intuitive like this . for example, if ones clicks the state topic in the slave’s frontend, it shows source being gps, while I would have hoped it t show bluetooth. have to reconsider if this is the way to proceed, to propagate Bluetooth devices form 1 instance to the other.
Hi.
For what I’m understanding with the MQTT statestream is possible to connect two instances of Hass.io. Can they be on different networks?
For example: Master is 192.168.1.101 and slave is 192.168.2.101
My “slave” HA has to be configured with the same broker ip of the master one or they can have two different IP address?
For example: Master is 192.168.1.102 and slave is 192.168.2.102
If I want to control my second Hass.io with my master one, can I use a configuration like this:
How many devices to you want to control? If its just one light, its easier to manually set that up, if you want all the switches and light, then try this. (I am not sure this can be done in hassio as this is in HA in the configuration.yaml
And it seems to work because on MQTTFX I can see events in logs when I turn on/off a light.
BUT I don’t know how to publish a message to turn on/off my light…
EDIT : Well if I’m right we can just send the state of entities but cannot SET their state right ?