-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
Empty eventData results in "Unparseable value: {'0': 0}" #134172
Comments
Hey there @home-assistant/z-wave, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) zwave_js documentation |
Looks like there may be two issues here. The first is that there's something odd with how your device is reporting that notification, and I'm not sure it's valid behavior. I would recommend also reporting the issue to https://github.com/zwave-js/node-zwave-js as they might want to implement some fix to handle this possibly invalid case. This is the report from the device:
It reports data type The second problem is looking like a result of a breaking change in Z-Wave JS v14 that isn't accounted for by the zwave-js-server. In the v14 migration guide section "Replaced Node.js Buffer with Uint8Array or portable Bytes class":
The
Indeed it's breaking because you can see this 0-byte array reported by the device is no longer encoded as a stringified Buffer as the Python library is expecting, so it asserts in the code you identified. This data was incoming from the server as shown in the websocket log message:
So the zwave-js-server needs to properly convert The same notification event in driver v13.10.3 should work fine, so if you have the option downgrading that would workaround this. |
So just to double check, you believe that I should open this as an issue in both https://github.com/home-assistant-libs/zwave-js-server-python and https://github.com/zwave-js/node-zwave-js as the first should get error handling for these cases, and the latter should fix the stringification of the JSON objects? |
No, no, no... I'm suggesting you submit a bug to node-zwave-js to ask whether event data should be returned for the NA data type. Not sure if that behavior is expected or not, they may be fine with the current behavior, I think it's weird. Submitting the issue is up to you. node-zwave-js has nothing to do with the conversion of the event data to JSON, that's zwave-js-server. Otherwise, this issue is fine. |
The problem
The connection to the zwave js server crashes upon receiving a notification with an empty eventData field due to parsing it as a dictionary.
What version of Home Assistant Core has the issue?
2024.12.5
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Supervised
Integration causing the issue
Z-Wave JS
Link to integration documentation on our website
https://www.home-assistant.io/integrations/zwave_js/
Diagnostics information
config_entry-zwave_js-01JFYDDACXK5C1E41E4M2E843W.json
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
The device is a philio tech PSK01 (which I know you can read from the diagnostics etc). Upon entering the correct user code and pressing "Disarm", the device seemingly sends three notifications which are the following:
Only the one with the empty eventData seems to be causing this issue.
If I interpret things correctly, https://github.com/home-assistant-libs/zwave-js-server-python is used for communicating with the addon. The issue lies there, and seems to be from the following trace:
client.py->listen()->receive_until_closed()->_handle_incoming_message()
then row 533,
self.driver.receive_event(event)
which leads to line 99 in driver.py:
DRIVER_EVENT_MODEL_MAP[event.type].from_dict(event.data)
which due to the eventType field of the faulty notification leads to a creation of an
EntryControlNotification (defined in notification.py, called via from_dict in event.py)
Row 81/82 in notification.py looks as follows:
where parse_buffer is defined in helpers.py, which calls parse_buffer_from_dict. In this file on row 42, the error is thrown.
I believe the issue to be triggered by the JSON parsing in client.py, _receive_json_or_raise(). This interprets the empty eventData from the addon, and somehow expects a dict and interprets None/empty as
{'0': 0}
. If the parsing there is expected to behave this way, I believe that row 81 in notification.py needs to check ifself.data["args"].get("eventData") is not {'0': 0}
before calling parse_buffer.Since the issue seems to be upstream from this project, I presume that I should open this as an issue there as well?
(Their issue template states: "Please report issues with Z-Wave JS in the Home Assistant core repository unless a developer told you otherwise. ", hence the post here. Plus that possible fixes will eventually have to be integrated here.)
Thanks in advance!
The text was updated successfully, but these errors were encountered: