Zwave2mqtt: [bug] HA integration fails when you set a name on a zwave device

Created on 4 Apr 2020  路  8Comments  路  Source: OpenZWave/Zwave2Mqtt

Version
Build/Run method: Manually built (git clone - npm install - npm run build )
Zwave2Mqtt version: master branch
Openzwave Version: master branch

Describe the bug
I'm using the HA integration with MQTT.
This works, but only when i do NOT set a name for the zwave device within zwave2mqtt. If i set the name, then it fails to work. This seems to be because the MQTT integration on the HA side uses the entity name, which by default uses the NodeID_XX format.

The message that HA publishes: homeassistant/nodeID_21/37/1/0/set True
The message that zwave2mqtt expects: homeassistant/plug1/37/1/0/set True
Plug1 is the name i gave the device.

To Reproduce
Steps to reproduce the behavior:

  1. Setup Zwave2mqtt
  2. Enable the HA integration.
  3. Set a name on the device
  4. Try the integraiton

Expected behavior
The MQTT from HA messages to be understood by zwave2mqtt.

Additional context
My suggestion would be that Zwave2Mqtt starts listening to the name of the device AND the id AND the nodeID_XX messages. This would fix the integration with HA.
I think this also might have to do with me pushing the the discovery for existing devices into HA and HA seeing the device name correctly, but the entities associated with that device still have the original name that it first got. So i think this could easily be a HA bug too.

Listening to multiple messages might not be the right fix, but it will at least make it work :)

bug

All 8 comments

I have to say, this is starting to feel more like a HA bug.

I've removed the MQTT integration from my configuration.yaml, restart and added it again. Had the names in zwave2mqtt changed and this didn't reflect. What's more, one of the nodes i had a name for in HA (so the name override) suggested it. So there's some form of caching in HA that's fishy here.

For others who might have this problem. I managed to get this to work by disabling the 'use name' option. You then have to do rediscover on all your items. Twice. :)

Quick question. In Z2M, on the node, there is a json discovery document for each of its "devices" (entities). Which mqtt paths do they describe?

HA should interact with those paths - or variations thereof.

Also, when changing from Names to Not-Names, it's a really good idea to clear the MQTT broker of topics related to Z2M. If retaining is set, HA will re-discover all the non-functional devices again.

Here's an example of one:


{
  "type": "sensor",
  "object_id": "electricity_a_meter",
  "discovery_payload": {
    "value_template": "{{ value_json.value }}",
    "device_class": "power",
    "unit_of_measurement": "A",
    "state_topic": "homeassistant/19/50/1/5",
    "json_attributes_topic": "homeassistant/19/50/1/5",
    "device": {
      "identifiers": [
        "zwave2mqtt_0xcedefd0b_node19"
      ],
      "manufacturer": "TKB Home",
      "model": "TZ69E Smart energy plug in switch (0x0103)",
      "name": "mediacentre",
      "sw_version": "Unknown"
    },
    "name": "mediacentre_electricity_a_meter",
    "unique_id": "zwave2mqtt_0xcedefd0b_19-50-1-5"
  },
  "discoveryTopic": "sensor/mediacentre/electricity_a_meter/config",
  "values": [
    "50-1-5"
  ],
  "persistent": false,
  "id": "sensor_electricity_a_meter"
}

This is from one that's working.

I used to have these values stored, this i think is not a good idea as then it uses the stored values. The store option is now also off.

So, i raised this item, but i believe it's configuration that caused it. The integration is working fine. I will see if i can find some time to update the docs to reflect my configuration better as that would be needed.

I also think that this should be turned into a feature request, as i do think that Z2M can handle this better.

Z2M firstly is born as a simple zwave2mqtt gateway, HASS integration is born after many users have ask for it.

That said, you can manage valueId nodes and their topic with an high level of customization, hass discovery is made after a node is ready, so if you make changes like change its name or something else that changes the topic of the values, or if you store its disovery values and then you change something that changes the discovery topic this will break for sure the comminucation with hass as the discovery is static.

In this cases what you have to do is to manually call update discovery from the UI so I will completely recalc all discovery configuration with the updated topic values.

This is not a bug at all but it's just a wrong use of the gateway. You should enable hass discovery only one your network is completely configured

I agree.
Thanks for explaining. This will be help for for others!

@cyclops1982 @LordMike I'm not an HASS user so I don't know the problems that users could have when they first start to use z2m with hass. I would be glad if someone of you could write a section like 'Hass quick start' or something like that with useful informations and step by step guide for newbies that are using z2m, maybe this will save from many question/issues in future :)

It will! I'll try to see if i can find the time.

For now, this software is really making life with HASS easier! Really keep up the good work!

Was this page helpful?
0 / 5 - 0 ratings