Skip to content

Commit a6338f4

Browse files
authored
More refactoring (#368)
* More refactoring * remove extra class definition
1 parent 4a282e6 commit a6338f4

File tree

4 files changed

+68
-76
lines changed

4 files changed

+68
-76
lines changed

zwave_js_server/model/controller/__init__.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
"""Provide a model for the Z-Wave JS controller."""
22
from dataclasses import dataclass
3-
from typing import (
4-
TYPE_CHECKING,
5-
Any,
6-
Dict,
7-
List,
8-
Literal,
9-
Optional,
10-
Union,
11-
cast,
12-
)
3+
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Union, cast
134

145
from ...const import (
156
MINIMUM_QR_STRING_LENGTH,
@@ -22,14 +13,14 @@
2213
from ...event import Event, EventBase
2314
from ...util.helpers import convert_base64_to_bytes, convert_bytes_to_base64
2415
from ..association import Association, AssociationGroup
25-
from .statistics import ControllerStatistics
2616
from ..node import Node
17+
from .data_model import ControllerDataType
2718
from .inclusion_and_provisioning import (
2819
InclusionGrant,
2920
ProvisioningEntry,
3021
QRProvisioningInformation,
3122
)
32-
from .data_model import ControllerDataType
23+
from .statistics import ControllerStatistics
3324

3425
if TYPE_CHECKING:
3526
from ...client import Client

zwave_js_server/model/controller/inclusion_and_provisioning.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ def from_dict(cls, data: Dict[str, Any]) -> "ProvisioningEntry":
6868
)
6969

7070

71-
@dataclass
72-
class NVMProgress:
73-
"""Class to represent an NVM backup/restore progress event."""
74-
75-
bytes_read_or_written: int
76-
total_bytes: int
77-
78-
7971
@dataclass
8072
class QRProvisioningInformationMixin:
8173
"""Mixin class to represent the base fields of a QR provisioning information."""

zwave_js_server/model/node/__init__.py

Lines changed: 12 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Provide a model for the Z-Wave JS node."""
2-
from typing import TYPE_CHECKING, Any, Dict, List, Optional, TypedDict, Union, cast
2+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast
33

44
from ...const import (
55
INTERVIEW_FAILED,
@@ -17,22 +17,15 @@
1717
UnwriteableValue,
1818
)
1919
from ..command_class import CommandClassInfo
20-
from ..device_class import DeviceClass, DeviceClassDataType
21-
from ..device_config import DeviceConfig, DeviceConfigDataType
22-
from ..endpoint import Endpoint, EndpointDataType
20+
from ..device_class import DeviceClass
21+
from ..device_config import DeviceConfig
22+
from ..endpoint import Endpoint
2323
from ..firmware import (
2424
FirmwareUpdateFinished,
2525
FirmwareUpdateFinishedDataType,
2626
FirmwareUpdateProgress,
2727
FirmwareUpdateProgressDataType,
2828
)
29-
from .health_check import (
30-
CheckHealthProgress,
31-
LifelineHealthCheckSummary,
32-
RouteHealthCheckSummary,
33-
TestPowerLevelProgress,
34-
)
35-
from .statistics import NodeStatistics, NodeStatisticsDataType
3629
from ..notification import (
3730
EntryControlNotification,
3831
EntryControlNotificationDataType,
@@ -51,56 +44,19 @@
5144
_get_value_id_from_dict,
5245
_init_value,
5346
)
47+
from .data_model import NodeDataType
48+
from .health_check import (
49+
CheckHealthProgress,
50+
LifelineHealthCheckSummary,
51+
RouteHealthCheckSummary,
52+
TestPowerLevelProgress,
53+
)
54+
from .statistics import NodeStatistics
5455

5556
if TYPE_CHECKING:
5657
from ...client import Client
5758

5859

59-
class NodeDataType(TypedDict, total=False):
60-
"""Represent a node data dict type."""
61-
62-
nodeId: int # required
63-
index: int # required
64-
deviceClass: DeviceClassDataType # required
65-
installerIcon: int
66-
userIcon: int
67-
name: str
68-
location: str
69-
status: int # 0-4 # required
70-
zwavePlusVersion: int
71-
zwavePlusNodeType: int
72-
zwavePlusRoleType: int
73-
isListening: bool
74-
isFrequentListening: Union[bool, str]
75-
isRouting: bool
76-
maxDataRate: int
77-
supportedDataRates: List[int]
78-
isSecure: bool
79-
supportsBeaming: bool
80-
supportsSecurity: bool
81-
protocolVersion: int
82-
firmwareVersion: str
83-
manufacturerId: int
84-
productId: int
85-
productType: int
86-
deviceConfig: DeviceConfigDataType
87-
deviceDatabaseUrl: str
88-
keepAwake: bool
89-
ready: bool
90-
label: str
91-
endpoints: List[EndpointDataType]
92-
endpointCountIsDynamic: bool
93-
endpointsHaveIdenticalCapabilities: bool
94-
individualEndpointCount: int
95-
aggregatedEndpointCount: int
96-
interviewAttempts: int
97-
interviewStage: Optional[Union[int, str]]
98-
values: List[ValueDataType]
99-
statistics: NodeStatisticsDataType
100-
highestSecurityClass: int
101-
isControllerNode: bool
102-
103-
10460
class Node(EventBase):
10561
"""Represent a Z-Wave JS node."""
10662

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""Provide a model for the Z-Wave JS controller."""
2+
from typing import List, Optional, TypedDict, Union
3+
4+
from ..device_class import DeviceClassDataType
5+
from ..device_config import DeviceConfigDataType
6+
from ..endpoint import EndpointDataType
7+
from ..value import ValueDataType
8+
from .statistics import NodeStatisticsDataType
9+
10+
11+
class NodeDataType(TypedDict, total=False):
12+
"""Represent a node data dict type."""
13+
14+
nodeId: int # required
15+
index: int # required
16+
deviceClass: DeviceClassDataType # required
17+
installerIcon: int
18+
userIcon: int
19+
name: str
20+
location: str
21+
status: int # 0-4 # required
22+
zwavePlusVersion: int
23+
zwavePlusNodeType: int
24+
zwavePlusRoleType: int
25+
isListening: bool
26+
isFrequentListening: Union[bool, str]
27+
isRouting: bool
28+
maxDataRate: int
29+
supportedDataRates: List[int]
30+
isSecure: bool
31+
supportsBeaming: bool
32+
supportsSecurity: bool
33+
protocolVersion: int
34+
firmwareVersion: str
35+
manufacturerId: int
36+
productId: int
37+
productType: int
38+
deviceConfig: DeviceConfigDataType
39+
deviceDatabaseUrl: str
40+
keepAwake: bool
41+
ready: bool
42+
label: str
43+
endpoints: List[EndpointDataType]
44+
endpointCountIsDynamic: bool
45+
endpointsHaveIdenticalCapabilities: bool
46+
individualEndpointCount: int
47+
aggregatedEndpointCount: int
48+
interviewAttempts: int
49+
interviewStage: Optional[Union[int, str]]
50+
values: List[ValueDataType]
51+
statistics: NodeStatisticsDataType
52+
highestSecurityClass: int
53+
isControllerNode: bool

0 commit comments

Comments
 (0)