Can I send an mqtt message when z-wave switch status changes?

I have Node-Red running on another Pi that needs to know when a Z-wave switch controlled by Home Assistant changes its status. (To reflect the switch status on the Node-red dashboard). How would I trigger an MQTT message when the Z-Wave switch goes on or off?

I suspect automation, but that’s way beyond my experience. If I am right, could someone point me to an example?

I do this all the time with node-red. I use the home assistant component along with the MQTT component. Here’s a sample flow. Node-red is pretty easy to use. I found it a lot easier and more powerful than automations. You can install it as an add on.

[{"id":"eee21803.27d698","type":"server-state-changed","z":"33715402.5f5d5c","name":"Check Light","server":"578e6426.d083ac","entityidfilter":"light.living_room_lights_level","entityidfiltertype":"substring","haltifstate":"","x":80,"y":620,"wires":[["28802b3b.fa54f4"]]},{"id":"28802b3b.fa54f4","type":"mqtt out","z":"33715402.5f5d5c","name":"local","topic":"light/living_room","qos":"","retain":"false","broker":"68c7942b.be311c","x":230,"y":620,"wires":[]},{"id":"578e6426.d083ac","type":"server","z":"","name":"Home Assistant","url":"http://192.168.3.5:8123","pass":"6tgkQJVAtnAeTQqU"},{"id":"68c7942b.be311c","type":"mqtt-broker","z":null,"name":"local","broker":"192.168.1.10","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

1 Like

Thanks, I hope it’s that easy. I’ll be testing that later tonight.
But I have a new problem.

When I dropped your flow into my Node-Red, changed the servers in the configs, then deployed, I started getting this error message every second:

"Home assistant connection failed with error: Connection to home assistant could not be established with config: http://192.168.3.5:8123 <password redacted>"

And now it won’t go away, even if I delete the flow and re-deploy. Do you recognize that IP? Any idea where that error is coming from and how can I stop it?

Yup, that’s my HA IP. You should have a Home Assistant configuration node. You’ll need to update the IP there along with the API password. I’ll also be updating my API password since I just shared it with the world.

I finally made it stop with help from a couple of guys on the Node Red forum.
You probably exported the current flow, not the selected nodes.
I needed to shut-down and restart the Pi to stop the errors.

All is good as the State Change node does exactly what I want, so all is good now and your input is much appreciated.

Sig