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
15 changes: 3 additions & 12 deletions zwave_js_server/model/controller/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
"""Provide a model for the Z-Wave JS controller."""
from dataclasses import dataclass
from typing import (
TYPE_CHECKING,
Any,
Dict,
List,
Literal,
Optional,
Union,
cast,
)
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Union, cast

from ...const import (
MINIMUM_QR_STRING_LENGTH,
Expand All @@ -22,14 +13,14 @@
from ...event import Event, EventBase
from ...util.helpers import convert_base64_to_bytes, convert_bytes_to_base64
from ..association import Association, AssociationGroup
from .statistics import ControllerStatistics
from ..node import Node
from .data_model import ControllerDataType
from .inclusion_and_provisioning import (
InclusionGrant,
ProvisioningEntry,
QRProvisioningInformation,
)
from .data_model import ControllerDataType
from .statistics import ControllerStatistics

if TYPE_CHECKING:
from ...client import Client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ def from_dict(cls, data: Dict[str, Any]) -> "ProvisioningEntry":
)


@dataclass
class NVMProgress:
"""Class to represent an NVM backup/restore progress event."""

bytes_read_or_written: int
total_bytes: int


@dataclass
class QRProvisioningInformationMixin:
"""Mixin class to represent the base fields of a QR provisioning information."""
Expand Down
68 changes: 12 additions & 56 deletions zwave_js_server/model/node/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Provide a model for the Z-Wave JS node."""
from typing import TYPE_CHECKING, Any, Dict, List, Optional, TypedDict, Union, cast
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast

from ...const import (
INTERVIEW_FAILED,
Expand All @@ -17,22 +17,15 @@
UnwriteableValue,
)
from ..command_class import CommandClassInfo
from ..device_class import DeviceClass, DeviceClassDataType
from ..device_config import DeviceConfig, DeviceConfigDataType
from ..endpoint import Endpoint, EndpointDataType
from ..device_class import DeviceClass
from ..device_config import DeviceConfig
from ..endpoint import Endpoint
from ..firmware import (
FirmwareUpdateFinished,
FirmwareUpdateFinishedDataType,
FirmwareUpdateProgress,
FirmwareUpdateProgressDataType,
)
from .health_check import (
CheckHealthProgress,
LifelineHealthCheckSummary,
RouteHealthCheckSummary,
TestPowerLevelProgress,
)
from .statistics import NodeStatistics, NodeStatisticsDataType
from ..notification import (
EntryControlNotification,
EntryControlNotificationDataType,
Expand All @@ -51,56 +44,19 @@
_get_value_id_from_dict,
_init_value,
)
from .data_model import NodeDataType
from .health_check import (
CheckHealthProgress,
LifelineHealthCheckSummary,
RouteHealthCheckSummary,
TestPowerLevelProgress,
)
from .statistics import NodeStatistics

if TYPE_CHECKING:
from ...client import Client


class NodeDataType(TypedDict, total=False):
"""Represent a node data dict type."""

nodeId: int # required
index: int # required
deviceClass: DeviceClassDataType # required
installerIcon: int
userIcon: int
name: str
location: str
status: int # 0-4 # required
zwavePlusVersion: int
zwavePlusNodeType: int
zwavePlusRoleType: int
isListening: bool
isFrequentListening: Union[bool, str]
isRouting: bool
maxDataRate: int
supportedDataRates: List[int]
isSecure: bool
supportsBeaming: bool
supportsSecurity: bool
protocolVersion: int
firmwareVersion: str
manufacturerId: int
productId: int
productType: int
deviceConfig: DeviceConfigDataType
deviceDatabaseUrl: str
keepAwake: bool
ready: bool
label: str
endpoints: List[EndpointDataType]
endpointCountIsDynamic: bool
endpointsHaveIdenticalCapabilities: bool
individualEndpointCount: int
aggregatedEndpointCount: int
interviewAttempts: int
interviewStage: Optional[Union[int, str]]
values: List[ValueDataType]
statistics: NodeStatisticsDataType
highestSecurityClass: int
isControllerNode: bool


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

Expand Down
53 changes: 53 additions & 0 deletions zwave_js_server/model/node/data_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""Provide a model for the Z-Wave JS controller."""
from typing import List, Optional, TypedDict, Union

from ..device_class import DeviceClassDataType
from ..device_config import DeviceConfigDataType
from ..endpoint import EndpointDataType
from ..value import ValueDataType
from .statistics import NodeStatisticsDataType


class NodeDataType(TypedDict, total=False):
"""Represent a node data dict type."""

nodeId: int # required
index: int # required
deviceClass: DeviceClassDataType # required
installerIcon: int
userIcon: int
name: str
location: str
status: int # 0-4 # required
zwavePlusVersion: int
zwavePlusNodeType: int
zwavePlusRoleType: int
isListening: bool
isFrequentListening: Union[bool, str]
isRouting: bool
maxDataRate: int
supportedDataRates: List[int]
isSecure: bool
supportsBeaming: bool
supportsSecurity: bool
protocolVersion: int
firmwareVersion: str
manufacturerId: int
productId: int
productType: int
deviceConfig: DeviceConfigDataType
deviceDatabaseUrl: str
keepAwake: bool
ready: bool
label: str
endpoints: List[EndpointDataType]
endpointCountIsDynamic: bool
endpointsHaveIdenticalCapabilities: bool
individualEndpointCount: int
aggregatedEndpointCount: int
interviewAttempts: int
interviewStage: Optional[Union[int, str]]
values: List[ValueDataType]
statistics: NodeStatisticsDataType
highestSecurityClass: int
isControllerNode: bool