Is it possible to communicate between 2 Raspberry Pi’s, one with Node-Red add-on in Home-Assistant and the other with Node-Red installed. The Broker lives on the Home-Assistant Raspi. I don’t manage to get a connection between the Node-Red Raspi and the Home-Assistant Raspi.
I use the port 1883.
I hope somebody can give me some help.
Thank you.
Yvonne
I run two instances of Node-Red. One on each Raspi.
The purpose is that I want connect some stuff to the remote Raspi, which I can control with the Home-Assistant Raspi with switches. When I run a Python script from the remote Raspi to the Home-Assistant Raspi, I get the following error: ‘Bad connection Returned code=’, 5. So I thought I use node-red on both Raspi’s, but on the remote Raspi I get the message disconnected under the MQTT node. So I don’t know how to continue.
Thanks.
You shouldn’t need to run more than one instance of NodeRed. I would remove the addon on your HA pi and just use your standalone NodeRed instance.
Then, install the websockets pallete. This will allow NodeRed and HA to communicate directly without having to use MQTT or any other kind of broker. It all happens using websockets.
As for the error code, you said you are using port 1883 on your standalone NodeRed? If that instance also has MQTT on it (set to the default port), you are getting a port conflict. NodeRed typically listens on 1880 while MQTT listens on 1883. If you have both set to 1883, that’s where your communication problem is.
Next problem. I deleted node-red from the RaspberryPi running Home-Assitant.
I created a token for the use in Node-Red on my other Raspberry Pi.
I installed the websockets pallete in Node-Red and created a flow:
[{“id”:“794aa7c9.f1a3b8”,“type”:“server-events”,“z”:“dd193c86.6249a”,“name”:“ReceiveWS”,“server”:“22ea8d4d.908282”,“event_type”:"",“exposeToHomeAssistant”:false,“haConfig”:[{“property”:“name”,“value”:""},{“property”:“icon”,“value”:""}],“waitForRunning”:true,“x”:1070,“y”:240,“wires”:[[“d56da6f4.a9d6d8”]]},{“id”:“d56da6f4.a9d6d8”,“type”:“debug”,“z”:“dd193c86.6249a”,“name”:"",“active”:true,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“payload”,“targetType”:“msg”,“x”:1430,“y”:240,“wires”:[]},{“id”:“22ea8d4d.908282”,“type”:“server”,“z”:"",“name”:“Home Assistant”,“legacy”:false,“addon”:false,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”,“connectionDelay”:true,“cacheJson”:true}]
But now how can I send information to this node using Home-Assistant?
I have a sensor detecting movement. Suppose I want a reaction in the node-red (switching an attached relais) what sort of code do I have to write? I see no documentation or at least I have no idea where to find. Must I write Python code and do I have to change the configuration file? Can you please give me some help and maybe an example. Sorry for the inconvenience and thank you for your help.
Yvonne
So, for a motion flow, you’ll want to use the events-state node (you’ll notice that there are a lot of nodes that get added with the websockets pallete). You don’t send anything from Home Assistant and you don’t have to write any code to make this happen. The websockets node connect to HA and listen for whatever events and/or entities you want them to. @Kermit has written a fantastic getting started guide: https://zachowj.github.io/node-red-contrib-home-assistant-websocket/guide/
Thank you for your answer. I understand.
I have 2 questions to begin with;)
First my Window Edit events has no For input box:
Second:
My raspberry Pi has a wired and a wireless connection. So 2 different IP addresses.
In Node-Red the event: status node says it is connected, but in Home-Assistent I have the notification Login attempt or request with invalid authentication from 192.168.xxx.xxx (192.168.xxx.xxx).
This is the wired connection.
I attached a debug node to the event: state node in order to get a message the moment the state changes, but no message appears when the movement is detected.
Under the state node I got the message that it is running, so I suppose it is connected to Home-Assistent, otherwise I would have the message disconnected.
I wrote the article you mentioned and that is working perfectly. So something is wrong in my configuration I suppose, but I have no idea what.
Hope you can and will help.
I have installed HACS in HA, but there is no integration for node-red in HACS.
I updated to 0.27 and that is now like yours.
I detached the wire, so only 1 connection now.
Thanks.