cgarwood / homeassistant-zwave_mqtt

Limited Pre-Release of the new OZW1.6 Z-Wave component. Currently has limited platform support. Check the README for more details.
72 stars 8 forks source link

Adding a node results in incomplete/wrong Devices and entities until HA is restarted #115

Open kpine opened 4 years ago

kpine commented 4 years ago

I added a node and the Device entries looked peculiar. There were many errors in the log too. Unfortunately I didn't get the zwave_mqtt debug logs because I wiped my config and forgot to enable them. I can try again if needed.

image

[homeassistant.helpers.entity_registry] Registered new sensor.zwave_mqtt entity: sensor.battery_level
[homeassistant.helpers.entity_registry] Registered new sensor.zwave_mqtt entity: sensor.indicator
[homeassistant.components.sensor] Not adding entity : Indicator because it's disabled
[homeassistant.helpers.entity_registry] Registered new sensor.zwave_mqtt entity: sensor.instance_1_air_temperature
[homeassistant.helpers.entity_registry] Registered new sensor.zwave_mqtt entity: sensor.instance_1_air_temperature_units
[homeassistant.components.sensor] Not adding entity : Instance 1: Air Temperature Units because it's disabled
[homeassistant.helpers.entity_registry] Registered new sensor.zwave_mqtt entity: sensor.instance_1_humidity
[homeassistant.helpers.entity_registry] Registered new sensor.zwave_mqtt entity: sensor.instance_1_humidity_units
[homeassistant.components.sensor] Not adding entity : Instance 1: Humidity Units because it's disabled
[homeassistant.helpers.entity_registry] Registered new sensor.zwave_mqtt entity: sensor.instance_2_air_temperature
[homeassistant.helpers.entity_registry] Registered new sensor.zwave_mqtt entity: sensor.instance_2_air_temperature_units
[homeassistant.components.sensor] Not adding entity : Instance 2: Air Temperature Units because it's disabled
[homeassistant.helpers.entity_registry] Registered new sensor.zwave_mqtt entity: sensor.instance_2_humidity
[homeassistant.helpers.entity_registry] Registered new sensor.zwave_mqtt entity: sensor.instance_2_humidity_units
[homeassistant.components.sensor] Not adding entity : Instance 2: Humidity Units because it's disabled

After the restart it looks correct.

image

ozwd sent several messages during the AddNode, and the product information was blank, until it hit query stage complete. Is it possible that the device and entities were created before Complete was reached, and something was not updated? The fact that a restart fixed it was good (and maybe the device info was actually saved to the registry?), but it would be preferable to not require that. I believe the HA core z-wave integration waits until the product data is valid before making the node available.

{
    "NodeID": 3,
    "NodeQueryStage": "ProtocolInfo",
    "isListening": true,
    "isFlirs": false,
    "isBeaming": false,
    "isRouting": false,
    "isSecurityv1": false,
    "isZWavePlus": false,
    "isNIFRecieved": true,
    "isAwake": true,
    "isFailed": false,
    "MetaData": {
        "OZWInfoURL": "",
        "ZWAProductURL": "",
        "ProductPic": "",
        "Description": "",
        "ProductManualURL": "",
        "ProductPageURL": "",
        "InclusionHelp": "",
        "ExclusionHelp": "",
        "ResetHelp": "",
        "WakeupHelp": "",
        "ProductSupportURL": "",
        "Frequency": "",
        "Name": "",
        "ProductPicBase64": ""
    },
    "Event": "nodeNaming",
    "TimeStamp": 1588205900,
    "NodeManufacturerName": "",
    "NodeProductName": "",
    "NodeBasicString": "Routing Slave",
    "NodeBasic": 4,
    "NodeGenericString": "Thermostat",
    "NodeGeneric": 8,
    "NodeSpecificString": "General Thermostat V2",
    "NodeSpecific": 6,
    "NodeManufacturerID": "0x0000",
    "NodeProductType": "0x0000",
    "NodeProductID": "0x0000",
    "NodeBaudRate": 0,
    "NodeVersion": 0
}
{
    "NodeID": 3,
    "NodeQueryStage": "Complete",
    "isListening": true,
    "isFlirs": false,
    "isBeaming": false,
    "isRouting": false,
    "isSecurityv1": false,
    "isZWavePlus": true,
    "isNIFRecieved": true,
    "isAwake": true,
    "isFailed": false,
    "MetaData": {
        "OZWInfoURL": "",
        "ZWAProductURL": "",
        "ProductPic": "",
        "Description": "",
        "ProductManualURL": "",
        "ProductPageURL": "",
        "InclusionHelp": "",
        "ExclusionHelp": "",
        "ResetHelp": "",
        "WakeupHelp": "",
        "ProductSupportURL": "",
        "Frequency": "",
        "Name": "",
        "ProductPicBase64": ""
    },
    "Event": "nodeQueriesComplete",
    "TimeStamp": 1588205906,
    "NodeManufacturerName": "2GIG Technologies",
    "NodeProductName": "CT32 Thermostat",
    "NodeBasicString": "Routing Slave",
    "NodeBasic": 4,
    "NodeGenericString": "Thermostat",
    "NodeGeneric": 8,
    "NodeSpecificString": "General Thermostat V2",
    "NodeSpecific": 6,
    "NodeManufacturerID": "0x0098",
    "NodeProductType": "0x2002",
    "NodeProductID": "0x0100",
    "NodeBaudRate": 100000,
    "NodeVersion": 4,
    "NodeName": "",
    "NodeLocation": "",
    "NodeDeviceTypeString": "Thermostat HVAC",
    "NodeDeviceType": 4608,
    "NodeRole": 7,
    "NodeRoleString": "Listening Sleeping Slave",
    "NodePlusType": 0,
    "NodePlusTypeString": "Z-Wave+ node",
    "Neighbors": [
        1,
        2
    ]
}
marcelveldt commented 4 years ago

Strange, this is exactly what was fixed. I'll take another look.

marcelveldt commented 4 years ago

BTW: In the log snippet you've sent there are no errors.

marcelveldt commented 4 years ago

You are 100% sure you tested this with version 0.0.13 ? This exact behaviour was fixed in 0.0.13... Just asking before I remove a node from my setup to re-add it again ;-)

kpine commented 4 years ago

Pretty sure, but I'll try again.

kpine commented 4 years ago

I can reproduce. I was definitely on 0.0.13, in fact I upgraded to 0.0.14 to reproduce again.

BTW: In the log snippet you've sent there are no errors.

I think you missed the part where the entity names have no device name prefix. It shouldn't be sensor.battery_level, it should be something like sensor.ct32_thermostat_battery_level or whatever.

I've attached the debug logs. Here's a screen shot of the entities, missing their device name prefix.

image

I stopped HA and checked the device registry file, the names look correct. After rebooting the device names are correct in the UI. The entities however were recorded with the bad names.

hass_add_node.txt

marcelveldt commented 4 years ago

OK, this is strange because this is exactly what I fixed in a previous PR and tested myself. I will try this again to see what's going on. Just to be sure: You did refresh the browser ? It is true that the device name itself comes through much later in the interview process but that is exactly why we created the new update method in core hass device registry.

kpine commented 4 years ago

Yes, I did refresh. The bigger problem is the creation of the entities though, they are stored before the device name is seen apparently.

marcelveldt commented 4 years ago

That's no issue at all as the name will get updated afterwards. Anyways I will take another look at it asap

marcelveldt commented 4 years ago

I just published version .15 to HACS, please have a test with that. As we're already implementing the code into core Hass it would be great to get some feedback if this issue is resolved.

WARNING: version .15 contained a change to the internal id matching so it is normal that you need to rename your entities/devices again.

kpine commented 4 years ago

I tried again and can't really say this is fixed because after adding the node there is no new Device entry or entities at all, even after refreshing (F5) the web page. After adding the node I have node 13 in the MQTT topics, but nothing in HA. The .storage files have no entries. After restarting HA the device and entities appear and are named correctly. In the HA log you can see node 13 was detected in the Add, but no entities were registered. After the restart they are registered.

It's strange because before trying version .15 I removed the integration, stopped HA, upgrade to .15 and restarted, then re-added the integration and all the existing nodes were detected fine (AFAIK). Just to be sure, I repeated the process twice, with the same results. I am running the latest version of this component.

$ git log --oneline -n1
3f005ea (HEAD -> master, tag: v0.0.15, tag: untagged-def09014fcd2b429703a, origin/master, origin/HEAD) fix node update (#125)

Attached are the mqtt dump and HA logs.

ha.txt mqtt_dump.txt