From 220cb57addf2a7022af941a5eb0d1c051016278e Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Thu, 21 Apr 2022 08:14:39 -0400 Subject: [PATCH] Bump zwave-js-server-python to 0.35.3 (#70357) --- homeassistant/components/zwave_js/__init__.py | 20 ++++++++-------- .../components/zwave_js/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/zwave_js/test_events.py | 23 +++++++++++++++++++ 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/zwave_js/__init__.py b/homeassistant/components/zwave_js/__init__.py index 12ff9acb530515..fa87ad954add94 100644 --- a/homeassistant/components/zwave_js/__init__.py +++ b/homeassistant/components/zwave_js/__init__.py @@ -4,6 +4,7 @@ import asyncio from collections import defaultdict from collections.abc import Callable +from typing import Any from async_timeout import timeout from zwave_js_server.client import Client as ZwaveClient @@ -289,12 +290,7 @@ async def async_on_node_ready(node: ZwaveNode) -> None: ) ) # add listener for stateless node notification events - entry.async_on_unload( - node.on( - "notification", - lambda event: async_on_notification(event["notification"]), - ) - ) + entry.async_on_unload(node.on("notification", async_on_notification)) async def async_on_node_added(node: ZwaveNode) -> None: """Handle node added event.""" @@ -402,12 +398,14 @@ def async_on_value_notification(notification: ValueNotification) -> None: ) @callback - def async_on_notification( - notification: EntryControlNotification - | NotificationNotification - | PowerLevelNotification, - ) -> None: + def async_on_notification(event: dict[str, Any]) -> None: """Relay stateless notification events from Z-Wave nodes to hass.""" + if "notification" not in event: + LOGGER.info("Unknown notification: %s", event) + return + notification: EntryControlNotification | NotificationNotification | PowerLevelNotification = event[ + "notification" + ] device = dev_reg.async_get_device({get_device_id(client, notification.node)}) # We assert because we know the device exists assert device diff --git a/homeassistant/components/zwave_js/manifest.json b/homeassistant/components/zwave_js/manifest.json index cdc81b9478bb62..0598f6812c51a1 100644 --- a/homeassistant/components/zwave_js/manifest.json +++ b/homeassistant/components/zwave_js/manifest.json @@ -3,7 +3,7 @@ "name": "Z-Wave JS", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/zwave_js", - "requirements": ["zwave-js-server-python==0.35.2"], + "requirements": ["zwave-js-server-python==0.35.3"], "codeowners": ["@home-assistant/z-wave"], "dependencies": ["usb", "http", "websocket_api"], "iot_class": "local_push", diff --git a/requirements_all.txt b/requirements_all.txt index 776c5375f687c1..dbc0ea1ad47cba 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2503,7 +2503,7 @@ zigpy==0.44.2 zm-py==0.5.2 # homeassistant.components.zwave_js -zwave-js-server-python==0.35.2 +zwave-js-server-python==0.35.3 # homeassistant.components.zwave_me zwave_me_ws==0.2.4 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index b5f91a4aa55d68..d1d44cdfa445e3 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1625,7 +1625,7 @@ zigpy-znp==0.7.0 zigpy==0.44.2 # homeassistant.components.zwave_js -zwave-js-server-python==0.35.2 +zwave-js-server-python==0.35.3 # homeassistant.components.zwave_me zwave_me_ws==0.2.4 diff --git a/tests/components/zwave_js/test_events.py b/tests/components/zwave_js/test_events.py index 32859ae3c37dbd..5085175de83012 100644 --- a/tests/components/zwave_js/test_events.py +++ b/tests/components/zwave_js/test_events.py @@ -307,3 +307,26 @@ async def test_unknown_notification(hass, hank_binary_switch, integration, clien notification_obj.node = node with pytest.raises(TypeError): node.emit("notification", {"notification": notification_obj}) + + notification_events = async_capture_events(hass, "zwave_js_notification") + + # Test a valid notification with an unsupported command class + event = Event( + type="notification", + data={ + "source": "node", + "event": "notification", + "nodeId": node.node_id, + "ccId": 0, + "args": { + "commandClassName": "No Operation", + "commandClass": 0, + "testNodeId": 1, + "status": 0, + "acknowledgedFrames": 2, + }, + }, + ) + node.receive_event(event) + + assert not notification_events