1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
"""
Model for Zwave Command Class Info.
https://zwave-js.github.io/node-zwave-js/#/api/endpoint?id=commandclasses
"""
from __future__ import annotations
from typing import TypedDict
from ..const import CommandClass
class CommandClassInfoDataType(TypedDict):
"""Represent a command class info data dict type."""
id: int
name: str
version: int
isSecure: bool
class CommandClassInfo:
"""Model for a Zwave CommandClass Info."""
def __init__(self, data: CommandClassInfoDataType) -> None:
"""Initialize."""
self.data = data
@property
def id(self) -> int:
"""Return CommandClass ID."""
return self.data["id"]
@property
def command_class(self) -> CommandClass:
"""Return CommandClass."""
return CommandClass(self.id)
@property
def name(self) -> str:
"""Return friendly name for CommandClass."""
return self.data["name"]
@property
def version(self) -> int:
"""Return the CommandClass version used on this node/endpoint."""
return self.data["version"]
@property
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()
|