Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[homeassistant.components.zwave_js] Unexpected exception: 'protocolDataRate' #108021

Closed
maheus opened this issue Jan 14, 2024 · 22 comments
Closed

Comments

@maheus
Copy link
Contributor

maheus commented Jan 14, 2024

The problem

Hi,

after upgrade HA to 2023.11.3, i have an error with zwave js integration.
I'm using docker zwavejs2mqtt 9.6.2 version

zwave-js-ui: 9.6.2.6e369a1
zwave-js: 12.4.1

The log printing this error

2024-01-14 15:17:03.582 ERROR (MainThread) [homeassistant.components.zwave_js] Unexpected exception: 'protocolDataRate'
Traceback (most recent call last):
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/homeassistant/components/zwave_js/__init__.py", line 888, in client_listen
    await client.listen(driver_ready)
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/zwave_js_server/client.py", line 269, in listen
    await self._loop.run_in_executor(
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/zwave_js_server/model/driver.py", line 70, in __init__
    self.controller = Controller(client, state)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/zwave_js_server/model/controller/__init__.py", line 83, in __init__
    node = Node(client, node_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/zwave_js_server/model/node/__init__.py", line 113, in __init__
    self._statistics = NodeStatistics(
                       ^^^^^^^^^^^^^^^
  File "<string>", line 5, in __init__
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/zwave_js_server/model/node/statistics.py", line 62, in __post_init__
    self.lwr = RouteStatistics(self.client, lwr)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 5, in __init__
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/zwave_js_server/model/statistics.py", line 47, in __post_init__
    self.protocol_data_rate = ProtocolDataRate(self.data["protocolDataRate"])
                                               ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
KeyError: 'protocolDataRate'

What version of Home Assistant Core has the issue?

core-2023.11.3

What was the last working version of Home Assistant Core?

core-2023.9.X

What type of installation are you running?

Home Assistant Core

Integration causing the issue

zwave-js

Link to integration documentation on our website

https://www.home-assistant.io/integrations/zwave_js/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

Hey there @home-assistant/z-wave, mind taking a look at this issue as it has been labeled with an integration (zwave_js) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of zwave_js can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign zwave_js Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


zwave_js documentation
zwave_js source
(message by IssueLinks)

@maheus
Copy link
Contributor Author

maheus commented Jan 14, 2024

Zwave JS UI is ok and I see all my zwave node

@kpine
Copy link
Contributor

kpine commented Jan 14, 2024

Please attach the device diagnostic file (attach file to comment, not copy and paste). You can download the diagnostic file by going to Settings -> Devices & services -> Z-Wave "Devices" -> The Device -> Device info -> ... -> Download diagnostics.

Also capture the debug logs when the problem occurs and attach as a file here.

@maheus
Copy link
Contributor Author

maheus commented Jan 14, 2024

device diagnostic and debug log gives many details on my configuration and i'm not ok with this.
On debug logs i have a [zwave_js_server] Received message: with very big JSON who contains my zwave nodes's details.
after this i have
[zwave_js_server] Listen completed. Cleaning up
and finaly

2024-01-14 17:18:43.831 ERROR (MainThread) [homeassistant.components.zwave_js] Unexpected exception: 'protocolDataRate'
Traceback (most recent call last):
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/homeassistant/components/zwave_js/__init__.py", line 888, in client_listen
    await client.listen(driver_ready)
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/zwave_js_server/client.py", line 269, in listen
    await self._loop.run_in_executor(
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/zwave_js_server/model/driver.py", line 70, in __init__
    self.controller = Controller(client, state)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/zwave_js_server/model/controller/__init__.py", line 83, in __init__
    node = Node(client, node_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/zwave_js_server/model/node/__init__.py", line 113, in __init__
    self._statistics = NodeStatistics(
                       ^^^^^^^^^^^^^^^
  File "<string>", line 5, in __init__
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/zwave_js_server/model/node/statistics.py", line 62, in __post_init__
    self.lwr = RouteStatistics(self.client, lwr)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 5, in __init__
  File "/srv/homeassistant_3.11/lib/python3.11/site-packages/zwave_js_server/model/statistics.py", line 47, in __post_init__
    self.protocol_data_rate = ProtocolDataRate(self.data["protocolDataRate"])
                                               ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
KeyError: 'protocolDataRate'
2024-01-14 17:18:43.900 INFO (MainThread) [homeassistant.components.zwave_js] Disconnected from server. Reloading integration
2024-01-14 17:18:43.913 DEBUG (MainThread) [homeassistant.components.zwave_js] Cancelling start client
2024-01-14 17:18:43.922 DEBUG (MainThread) [zwave_js_server] Trying to connect

@kpine
Copy link
Contributor

kpine commented Jan 14, 2024

device diagnostic

There isn't any personal information in the diagnostic, you can check yourself.

debug log gives many details on my configuration and i'm not ok with this.

You should at least provide the json message and the driver log messages that are causing the error. Otherwise there's nothing to help with.

@maheus
Copy link
Contributor Author

maheus commented Jan 14, 2024

I checked, the diagnostic or debug message export the number of zwave devices and many details on this devices and for me this is a personal informations .
i doesn't saw the the driver log messages, where is it please ?

@maheus
Copy link
Contributor Author

maheus commented Jan 14, 2024

in my json , i have this

                  "lwr": {
                    "repeaters": [
                      17
                    ]
                  }

or it seems that i must have this

    "lwr": {
      "protocolDataRate": 2,
      "repeaters": [],
      "rssi": -55,
      "repeaterRSSI": []
    }

@raman325
Copy link
Contributor

this seems like a bug in the driver. Either the typing is wrong, or the logic to populate lwr/nlwr is wrong because we always expect to get protocolDataRate and repeaters if any data for lwr is provided, whereas rssi and repeaterRSSI are optional. Normally I'd ask you to open an issue in the zwave-js/node-zwave-js repo but I will create it since I can probably explain the problem in better detail. Note that there may be a delayed response, I believe the main developer for the project is on paternity leave (see zwave-js/node-zwave-js#6521 (comment)).

@maheus
Copy link
Contributor Author

maheus commented Jan 15, 2024

thanks for your response @raman325. So I'll let you create the issue in zwave-js/node-zwave-js repo and I will follow it carefully

@raman325
Copy link
Contributor

sure - I will do so, but two things:

  1. That project also asks for DEBUG logs, and the issue will not go very far without them. I'm not sure how to help you if you are unwilling to provide these logs, we the developers explicitly added them to help us troubleshoot issues like this. The only information we see in the logs is communication between the controller, driver, and different nodes. Yes, we can see when certain states change but it would take a forensic analyst to turn that into anything useful if it's at all even possible.
  2. What information in the diagnostics do you feel is personal information? As @kpine said, we have redacted the information we thought could be personally identifiable or affect your security, like your network's home ID, the location property of each node, and lock user codes. The only thing I can think of is node name but unless you are putting your address in there in the majority of cases the only thing we learn about is what room in the house the device is for, which is meaningless. Like the DEBUG logs, we explicitly made decisions about what to include in the diagnostics which would enable us to troubleshoot issues like yours.

I understand your concern about security, we have that concern too, which is why I am comfortable saying that neither the logs nor the diagnostics will leak any information that could be used to find out who you are or find a way into your network/HA instance. I hope you can also appreciate that pushing back on these requests when someone is trying to help you is frustrating because we end up wasting time arguing and finding a needle in a haystack, assuming we can even do so.

I am logging the issue and tagging you in it, but I would HIGHLY recommend that you provide the DEBUG logs and diagnostics as soon as you can to reduce the wait time.

@maheus
Copy link
Contributor Author

maheus commented Jan 15, 2024

Ok I understand, i attaching the logs. Tell me if it's enough
home-assistant_zwave_js_2024-01-14T16-18-45.708Z.log

config_entry-zwave_js-723f774f23e86d4f9f488275e3c21a2c.json.txt

@kpine
Copy link
Contributor

kpine commented Jan 15, 2024

Have you tried re-interviewing the problem node?

@maheus
Copy link
Contributor Author

maheus commented Jan 15, 2024

@kpine if you grep -A4 lwr in config_entry file, you will see all node has not protocoldatarate

@kpine
Copy link
Contributor

kpine commented Jan 15, 2024

I understand what the problem is. If you are able to re-interview the node it might correct the source of the error.

Unfortunately you can't re-interview with the official Z-Wave JS add-on if the integration is crashing. Another case where an exception in the python library makes the software unusable. The integration should be able to handle this edge cases and allow some troubleshooting and debugging.

@maheus
Copy link
Contributor Author

maheus commented Jan 15, 2024

The Zwave JS UI works fine, only HA is on error

@kpine
Copy link
Contributor

kpine commented Jan 15, 2024

Then have you tried re-interviewing in Z-Wave JS UI?

@maheus
Copy link
Contributor Author

maheus commented Jan 15, 2024

I just did it

@maheus
Copy link
Contributor Author

maheus commented Jan 15, 2024

debug info for an re-interview node

  "statistics": {
    "commandsTX": 0,
    "commandsRX": 102,
    "commandsDroppedRX": 0,
    "commandsDroppedTX": 0,
    "timeoutResponse": 0,
    "lwr": {
      "repeaters": []
    },
    "lastSeen": "2024-01-15T22:16:31.286Z"

i think to dowgrade zwavejs2mqtt image to 8.15.0 and see the debug info

@maheus
Copy link
Contributor Author

maheus commented Jan 15, 2024

with 8.15.0 , lwr does not exists

  "statistics": {
    "commandsTX": 1,
    "commandsRX": 0,
    "commandsDroppedRX": 0,
    "commandsDroppedTX": 0,
    "timeoutResponse": 0,
    "rtt": 296.8
  },

I think since 8.2X.XX , lwr has added.

@maheus
Copy link
Contributor Author

maheus commented Jan 17, 2024

@kpine @raman325 do you have an idea ? My hypothesis seems you good ? Do you think if it is possible to fix the HA code with conditional test on presence or not of ProtocolDataRate in the json ?

@kpine
Copy link
Contributor

kpine commented Jan 17, 2024

The root problem is in the z-wave driver. According to the "API contract", this scenario is invalid. Ultimately the driver needs to be fixed.

I don't have any say in a solution, but I think adding a workaround to the python library should be done to ignore invalid route info, especially since there won't be any driver updates for a couple months. IMO the route information is not critical to functionality in HA and I don't think it's reasonable that a simple error crashes the integration.

The upstream driver issue is here. You should contribute your Z-Wave JS UI driver debug logs to help solve the issue.

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@issue-triage-workflows issue-triage-workflows bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 23, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants