How to get state changes (binary or zwave) to MQTT?

I’ve set up the zwave2mqtt plugin which has taken control of the zwave device (I cannot see it in HA any longer and my lovelace entities are gone)

Is it possible to have both the HA and zwave2mqtt both see my network?

Or is there another way to watch for the state of a switch/motion and take action? Maybe Node-Red on each of my pi’s?

Why? It’s in MQTT now. Just use MQTT to perform actions.

Hi m0e. The reason is that I have multiple HA’s around the house due to z-wave issues.

I’d like to have a dashboard of sensors on each HA but when I use the zwaveTomqtt, i loose all of that.

It also makes setting up new devices very troublesome doing it in the zwaveTomqtt as renaming, re-adding, isn’t as intuitive as the regular z-wave plugin.

Is there a way to have both or is NodeRed the best way to monitor state and send MQTT?

How do you lose all of that?

Why are you running multiple HA instances? This isn’t necessary.

Your zwave controller cannot be accessed by both, but again, you don’t need to. I guess I am confused as to why you think you need to do anything in Node Red regarding MQTT.

Your zwave2mqtt integrates with MQTT discovery on HA. HA sees the devices and adds them as sensors/lights/switches/etc to HA. You then have these devices available in HA to read state in Node red and create automations.

Please explain your setup, because I think you are looking at this with the wrong idea.

Hi Moe,

When I added the zwavetomqtt gateway, it seemed to have taken control of the z-wave stick from HA. In HA, the network wasn’t started and “start network” wouldn’t work. On lovelace, this is what is seen

In my situation, I need multiple HA’s because of the properties of the house I live in. Z-wave doesn’t seem to reach all the locations, even with plugged in wall z-wave devices that are supposed to function as repeaters. Concrete walls with rebar.

Ultimately, I’d like to achieve the following
Raspberry Pi in 2 locations that both have z-wave sticks with devices on them. Feed the state back to a central Node-Red VM on my server that I can easily control (and back up)

Thanks again m0e!

That’s exactly it’s purpose.

Because it isn’t supposed to connect to the zwave controller any more. That’s the job of zwave2mqtt. That’s the point of zwave2mqtt.

This doesn’t require multiple Home Assistant servers though. You just need a device to act as a zwave controller in these areas. Multiple Home Assistant instances is a waste of effort, time, and energy.

Again, you are using zwave2mqtt. EVERYTHING from zwave is being broadcast to MQTT, and if your HA is using MQTT Discovery, all the devices will show up in HA. Point both of your zwave2mqtt instances to the same broker (but give them each different client identifiers), and your HA will pick up every device, despite where it’s located. You will need to find these devices and rename them in zwave2mqtt interface or in HA interface.

You don’t need zwave2mqtt to send to node-red. You want all states of all devices to be in Home Assistant. Use the events and states from home assistant to trigger flows.

1 Like

After reading your post (Thanks again) I understand the reason for the zwavetomqtt. I think for my setup, it may be easier for me to just have the entities listed on each PI as to not confused them on multiple devices but bring the state back to a central location. How I bring that back could be MQTT or just Node-Red reading the remote state of a HA instance on a PI.

I’ve tried to disable zwaveTomqtt and bring up my network however, it seems like the config is gone, all the nodes are gone except for the controller.

In the debug, I can trigger a reed switch and see the message show in the logs, but the nodes are gone. Did I stuff up my system?

You are really making this much harder than it is.

You do not need multiple Home Assistant instances, and it only complicates the setup. Let zwave2mqtt control your zwave, and use ONE Home Assistant. Why do you want to maintain more than one when you don’t need it?

No, but you would probably need to restart home assistant to get it to read the zwave controller AFTER you shut down zwave2mqtt (Which again, I would recommend using)

Think about your setup, long and hard. Do you REALLY want multiple Home Assistant servers to manage? What benefit is that? You only need one in your case.

I think the thing you have to realise @eeze2 is that the entity names will be different under zwave2mqtt. You will need to rename them, or re-do your automations and lovelace.

Fortunately we have sed in linux.

Thanks m0e. Here is my rational and why we may disagree on the ease of us. When I add things with z-wave onboard that system, I can see the entities open and close. When I use zwaveTomqtt, i have to set up each entity to send events on topics to a centralized broker which then has to pluck them out, create entities on that centralized HA (did I say already that formatting is a PITA) and then create automations there.

Versus each PI having it’s own Node-Red to do the stuff I want, including MQTT as an option but I don’t have to create customer event to topics, edit configuration files and worry about formatting.

If you still disagree with my assessment above, then there is something i’m not understanding because for me, seeing the entities on a lovelace page on the PI is a indicator that things are working.

When you use zwave2mqtt and MQTT discovery on HA, all the entities are created automatically except for thermostats and fans. I even renamed my devices in zwave2mqtt and they showed up with the old names I had when I was running zwave directly on my home assistant.

Yeah…I see all my zwave2mqtt devices on Lovelace as well, so I’m failing to understand the logic here of maintaining different HA installations. Sounds like a lot more work ongoing rather than a one time “get them in the system properly” method.

So basically every update, you have to go through 2 different systems and fix breaking changes, etc. What a pain in the ass that will be.

Yeah, if you want to maintain 2 disparate systems, then go ahead, but it’s not necessary and doesn’t make any sense logically to me.

Thanks m0e for clarifying.

However, the part that made me look to my split system was the lack of any visibility in lovelace.
I’m surprised to see you write

Because when zwave2mqtt took over my system, all the entities were removed, errors in lovelove and the only zwave stuff I could do was in the add-on itself. I lost all control in HA to see those entities.

mqtt discovery never worked for me, maybe because of my topic structure or something, not sure…

Did you have to add a lot of configuration into your configuration.yaml or other systems to created switches, templates and automation scripting?

Eager to get this going as it was on my list of “holiday” stuff to get done…

Your device names likely changed as a result of the move. You have to understand that zwave2mqtt names them differently by default. Just because you don’t see the “old” device names in your frontend doesn’t mean they don’t exist.

If you have mqtt discovery enabled on HA, you simply need to make sure zwave2mqtt is sending the data out on the right topic.

These are my settings:

No. Like I said, mqtt discovery works perfectly. The ONLY devices I had to make entries for in configuration were my thermostats (I don’t have any fans on zwave) like the zwave2mqtt documentation says.

I don’t use automations in home assistant. Every automation goes through node red.

I renamed all the devices in zwave2mqtt to reflect the old names I had when zwave was running directly on HA, so I didn’t even have to fix my lovelace.

Example. This is a zwave switch. It came into zwave2mqtt with a funny name, so I named it this so that in my HA it would show up like it used to as switch.front_porch_lights_switch.

Notice the switch is missing at the end of the name, because zwave2mqtt is appending it to the end for me.

So the config topic that comes through my broker is:
homeassistant/switch/front_porch_lights/switch/config
The state/command topics are coming through as:
homeassistant/front_porch_lights/{zwave2mqtt numbers}

Appreciate all the help m0e. I’ve just went through and renamed all of my devices in HA and they show in up in lovelace as Eco1, Eco2, Eco3, etc. When you made the move, it sounds like yours were still there, but were renamed right? So a quick rename and they are back visable.

Do you know if the Node ID’s stay the same when moving to zwave2mqtt? That would be helpful.
Does your nodered primarily use mqtt to trigger a change rather than the HA state On/Off?

Is there any way to save my existing zwave configuration of 8 devices and all their names so if I stuff something up I don’t have to redo this?
edit: I just found a /config/zwcfg_0xff166786.xml file that has my stuff. I guess a backup of this should do it? If i need to restore, just add this config to the configuration.yaml and I should have all my devices back?

Yes, the node IDs are the same.

100% no. Home Assistant is my state machine, node red is the brains. I read the states from HA and act upon them. I do not want to mix mqtt in on node red. I want all state to be handled the HA way.

Your zwave configuration is already saved in a xml file in your config directory. Zwave reads that file for information about your zwave devices.

I assume you’re using hassio and the addon? I don’t know if the addon points to that same file or not. It’s used by your zwave controller to inform HA about what nodes are connected and their capabilities. It’s not really used by HA.

1 Like

Thanks m0e! I’ll give this a test tomorrow.

Main use cases were

  1. When motion detected in garage and the time is after 6pm, turn on the ceiling light.
    HA reads state of motion from z-wave motion, sends MQTT message to broker, node red picks it up and sends a websocket to a tuya/smartlife switch and light comes on
  2. Window/Door security - When in “arm” mode and depending upon which level, certain windows/doors opening and closing will trigger an SMS alert or twitter…

Thinking they will be easy with this approach using Node Red as I already have some knowledge there.

Cheers man!

This seems cumbersome. I have tuya bulbs in HA, so I would just do this:
zwave motion sensor changes state, HA passes that change to node red via the home assistant palette websocket, node red flow starts, going through a time range node, to verify it’s within a specific time, then call HA service to turn on the light.

If you are using automations in HA to pass to node red, you’re doing it wrong. :wink:

Yep. I get all that too. Only my door/window sensors are going through my alarm system, so I read their state from there, and not MQTT. Same concept though.

I basically use traffic nodes to control the flow of notifications. If alarm is armed, and a sensor gets triggered, it sends it over Telegram AND Pushover (this one is great because I can override do not disturb settings for REALLY important information, like an alarm being triggered)

If I don’t want notifications, I can disable notifications for certain things (motion sensors outside when working in yard, etc).

EDIT: Just after I typed this up, I got a delivery from FedEX. Thought I would share what that notification looks like.

Many thanks @flamingm0e or all the help. Definitely given me some new ideas and strengthened stability of the overall system as less components.

I’m going to try to do what I can in the single system (HA+NR) and only use inter-system messaging when needed.

Last one… How would you recommend a panel to turn off/on lights using distributed systems like I have? I’m thing to create a lovelace panel with some binary switches, that NR monitors and when they are enabled/disabled, send a message to the various PI’s that I have… Might even just use a MQTT app as that would remove an extra system and allow the tablet to talk directly to my broker.

Cheers!

What do you mean? If everything is in ONE HA, and the other systems are on MQTT, you can control everything from the ONE HA. You don’t need node red for that. Use MQTT switches and sensors (of if they are on zwave2mqtt, use autodiscovery, and all the devices will show up)

I cannot use one HA because of the distance and wall types here (distance, thick concrete and rebar) so I must use two HA’s. I’d like a single control panel (tablet) to turn off and on lights. Would you suggest using the MQTT App or interace to one of the HA’s as a master?