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

Add to_dict to CommandClassInfo #1059

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
18 changes: 11 additions & 7 deletions test/model/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
UnwriteableValue,
)
from zwave_js_server.model import endpoint as endpoint_pkg, node as node_pkg
from zwave_js_server.model.node import Node
from zwave_js_server.model.node.firmware import (
NodeFirmwareUpdateInfo,
NodeFirmwareUpdateStatus,
Expand Down Expand Up @@ -207,14 +208,17 @@ async def test_highest_security_value(lock_schlage_be469, ring_keypad):
assert ring_keypad.highest_security_class is None


async def test_command_classes(endpoints_with_command_classes):
async def test_command_classes(endpoints_with_command_classes: Node) -> None:
"""Test command_classes property on endpoint."""
assert len(endpoints_with_command_classes.endpoints[0].command_classes) == 17
assert endpoints_with_command_classes.endpoints[0].command_classes[0].id == 38
assert (
endpoints_with_command_classes.endpoints[0].command_classes[0].command_class
== CommandClass.SWITCH_MULTILEVEL
)
node = endpoints_with_command_classes
assert len(node.endpoints[0].command_classes) == 17
command_class_info = node.endpoints[0].command_classes[0]
assert command_class_info.id == 38
assert command_class_info.command_class == CommandClass.SWITCH_MULTILEVEL
assert command_class_info.name == "Multilevel Switch"
assert command_class_info.version == 2
assert command_class_info.is_secure is False
assert command_class_info.to_dict() == command_class_info.data


async def test_device_config(
Expand Down
4 changes: 4 additions & 0 deletions zwave_js_server/model/command_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ def version(self) -> int:
def is_secure(self) -> bool:
"""Return if the CommandClass is used securely on this node/endpoint."""
return self.data["isSecure"]

def to_dict(self) -> CommandClassInfoDataType:
"""Create a dictionary from itself."""
return self.data.copy()