Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions test/model/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from zwave_js_server.exceptions import (
FailedCommand,
NotFoundError,
NotificationHasUnsupportedCommandClass,
UnwriteableValue,
)
from zwave_js_server.model import endpoint as endpoint_pkg, node as node_pkg
Expand Down Expand Up @@ -803,7 +802,11 @@ async def test_notification(lock_schlage_be469: node_pkg.Node):
assert event.data["notification"].status == PowerLevelTestStatus.FAILED
assert event.data["notification"].acknowledged_frames == 2


async def test_notification_unknown(lock_schlage_be469: node_pkg.Node, caplog):
"""Test unrecognized command class notification events."""
# Validate that an unrecognized CC notification event raises Exception
node = lock_schlage_be469
event = Event(
type="notification",
data={
Expand All @@ -814,8 +817,9 @@ async def test_notification(lock_schlage_be469: node_pkg.Node):
},
)

with pytest.raises(NotificationHasUnsupportedCommandClass):
node.handle_notification(event)
node.handle_notification(event)

assert "notification" not in event.data


async def test_entry_control_notification(ring_keypad):
Expand Down
14 changes: 0 additions & 14 deletions zwave_js_server/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from .const import CommandClass

if TYPE_CHECKING:
from .event import Event
from .model.value import Value


Expand Down Expand Up @@ -157,16 +156,3 @@ def __init__(self, value: "Value", path: str) -> None:
"upstream issue with the driver or missing support for this data in the "
"library"
)


class NotificationHasUnsupportedCommandClass(BaseZwaveJSServerError):
"""Exception raised when notification is received for an unsupported CC."""

def __init__(self, event: "Event", command_class: CommandClass) -> None:
"""Initialize an invalid Command Class error."""
self.event_data = event.data
self.command_class = command_class
super().__init__(
"Notification received with unsupported command class "
f"{command_class.name}: {event.data}"
)
7 changes: 5 additions & 2 deletions zwave_js_server/model/node/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide a model for the Z-Wave JS node."""
import logging
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast

from ...const import (
Expand All @@ -12,7 +13,6 @@
from ...exceptions import (
FailedCommand,
NotFoundError,
NotificationHasUnsupportedCommandClass,
UnparseableValue,
UnwriteableValue,
)
Expand Down Expand Up @@ -58,6 +58,9 @@
from ...client import Client


_LOGGER = logging.getLogger(__package__)


class Node(EventBase):
"""Represent a Z-Wave JS node."""

Expand Down Expand Up @@ -789,7 +792,7 @@ def handle_notification(self, event: Event) -> None:
self, cast(PowerLevelNotificationDataType, event.data)
)
else:
raise NotificationHasUnsupportedCommandClass(event, command_class)
_LOGGER.info("Unhandled notification command class: %s", command_class.name)

def handle_firmware_update_progress(self, event: Event) -> None:
"""Process a node firmware update progress event."""
Expand Down