Skip to content

Commit

Permalink
Bump zwave-js-server-python to 0.35.3 (home-assistant#70357)
Browse files Browse the repository at this point in the history
  • Loading branch information
raman325 authored Apr 21, 2022
1 parent 8065346 commit 220cb57
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
20 changes: 9 additions & 11 deletions homeassistant/components/zwave_js/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/zwave_js/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions tests/components/zwave_js/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 220cb57

Please sign in to comment.