pyvlx 0.2.27__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyvlx/__init__.py +21 -0
- pyvlx/api/__init__.py +23 -0
- pyvlx/api/activate_scene.py +63 -0
- pyvlx/api/api_event.py +73 -0
- pyvlx/api/command_send.py +85 -0
- pyvlx/api/factory_default.py +34 -0
- pyvlx/api/frame_creation.py +202 -0
- pyvlx/api/frames/__init__.py +76 -0
- pyvlx/api/frames/alias_array.py +45 -0
- pyvlx/api/frames/frame.py +56 -0
- pyvlx/api/frames/frame_activate_scene.py +92 -0
- pyvlx/api/frames/frame_activation_log_updated.py +14 -0
- pyvlx/api/frames/frame_command_send.py +280 -0
- pyvlx/api/frames/frame_discover_nodes.py +64 -0
- pyvlx/api/frames/frame_error_notification.py +42 -0
- pyvlx/api/frames/frame_facory_default.py +32 -0
- pyvlx/api/frames/frame_get_all_nodes_information.py +218 -0
- pyvlx/api/frames/frame_get_limitation.py +127 -0
- pyvlx/api/frames/frame_get_local_time.py +38 -0
- pyvlx/api/frames/frame_get_network_setup.py +64 -0
- pyvlx/api/frames/frame_get_node_information.py +223 -0
- pyvlx/api/frames/frame_get_protocol_version.py +53 -0
- pyvlx/api/frames/frame_get_scene_list.py +82 -0
- pyvlx/api/frames/frame_get_state.py +47 -0
- pyvlx/api/frames/frame_get_version.py +72 -0
- pyvlx/api/frames/frame_helper.py +40 -0
- pyvlx/api/frames/frame_house_status_monitor_disable_cfm.py +14 -0
- pyvlx/api/frames/frame_house_status_monitor_disable_req.py +14 -0
- pyvlx/api/frames/frame_house_status_monitor_enable_cfm.py +14 -0
- pyvlx/api/frames/frame_house_status_monitor_enable_req.py +14 -0
- pyvlx/api/frames/frame_leave_learn_state.py +41 -0
- pyvlx/api/frames/frame_node_information_changed.py +57 -0
- pyvlx/api/frames/frame_node_state_position_changed_notification.py +84 -0
- pyvlx/api/frames/frame_password_change.py +114 -0
- pyvlx/api/frames/frame_password_enter.py +70 -0
- pyvlx/api/frames/frame_reboot.py +32 -0
- pyvlx/api/frames/frame_set_node_name.py +73 -0
- pyvlx/api/frames/frame_set_utc.py +45 -0
- pyvlx/api/frames/frame_status_request.py +212 -0
- pyvlx/api/get_all_nodes_information.py +46 -0
- pyvlx/api/get_limitation.py +64 -0
- pyvlx/api/get_local_time.py +34 -0
- pyvlx/api/get_network_setup.py +34 -0
- pyvlx/api/get_node_information.py +42 -0
- pyvlx/api/get_protocol_version.py +40 -0
- pyvlx/api/get_scene_list.py +49 -0
- pyvlx/api/get_state.py +43 -0
- pyvlx/api/get_version.py +34 -0
- pyvlx/api/house_status_monitor.py +52 -0
- pyvlx/api/leave_learn_state.py +33 -0
- pyvlx/api/password_enter.py +39 -0
- pyvlx/api/reboot.py +33 -0
- pyvlx/api/session_id.py +20 -0
- pyvlx/api/set_node_name.py +32 -0
- pyvlx/api/set_utc.py +31 -0
- pyvlx/api/status_request.py +48 -0
- pyvlx/config.py +54 -0
- pyvlx/connection.py +182 -0
- pyvlx/const.py +685 -0
- pyvlx/dataobjects.py +161 -0
- pyvlx/discovery.py +100 -0
- pyvlx/exception.py +26 -0
- pyvlx/heartbeat.py +79 -0
- pyvlx/klf200gateway.py +167 -0
- pyvlx/lightening_device.py +102 -0
- pyvlx/log.py +4 -0
- pyvlx/node.py +74 -0
- pyvlx/node_helper.py +165 -0
- pyvlx/node_updater.py +162 -0
- pyvlx/nodes.py +99 -0
- pyvlx/on_off_switch.py +44 -0
- pyvlx/opening_device.py +644 -0
- pyvlx/parameter.py +357 -0
- pyvlx/py.typed +0 -0
- pyvlx/pyvlx.py +124 -0
- pyvlx/scene.py +53 -0
- pyvlx/scenes.py +60 -0
- pyvlx/slip.py +48 -0
- pyvlx/string_helper.py +20 -0
- pyvlx-0.2.27.dist-info/METADATA +122 -0
- pyvlx-0.2.27.dist-info/RECORD +84 -0
- pyvlx-0.2.27.dist-info/WHEEL +5 -0
- pyvlx-0.2.27.dist-info/licenses/LICENSE +165 -0
- pyvlx-0.2.27.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""Module for sending command to gw."""
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from pyvlx.const import Command, Originator, Priority, Velocity
|
|
6
|
+
|
|
7
|
+
from .frame import FrameBase
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class FrameActivateSceneRequest(FrameBase):
|
|
11
|
+
"""Frame for sending command to gw."""
|
|
12
|
+
|
|
13
|
+
PAYLOAD_LEN = 6
|
|
14
|
+
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
scene_id: Optional[int] = None,
|
|
18
|
+
session_id: Optional[int] = None,
|
|
19
|
+
originator: Originator = Originator.USER,
|
|
20
|
+
velocity: Velocity = Velocity.DEFAULT,
|
|
21
|
+
):
|
|
22
|
+
"""Init Frame."""
|
|
23
|
+
super().__init__(Command.GW_ACTIVATE_SCENE_REQ)
|
|
24
|
+
self.scene_id = scene_id
|
|
25
|
+
self.session_id = session_id
|
|
26
|
+
self.originator = originator
|
|
27
|
+
self.priority = Priority.USER_LEVEL_2
|
|
28
|
+
self.velocity = velocity
|
|
29
|
+
|
|
30
|
+
def get_payload(self) -> bytes:
|
|
31
|
+
"""Return Payload."""
|
|
32
|
+
assert self.session_id is not None
|
|
33
|
+
assert self.scene_id is not None
|
|
34
|
+
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
|
|
35
|
+
ret += bytes([self.originator.value])
|
|
36
|
+
ret += bytes([self.priority.value])
|
|
37
|
+
ret += bytes([self.scene_id])
|
|
38
|
+
ret += bytes([self.velocity.value])
|
|
39
|
+
return ret
|
|
40
|
+
|
|
41
|
+
def from_payload(self, payload: bytes) -> None:
|
|
42
|
+
"""Init frame from binary data."""
|
|
43
|
+
self.session_id = payload[0] * 256 + payload[1]
|
|
44
|
+
self.originator = Originator(payload[2])
|
|
45
|
+
self.priority = Priority(payload[3])
|
|
46
|
+
self.scene_id = payload[4]
|
|
47
|
+
self.velocity = Velocity(payload[5])
|
|
48
|
+
|
|
49
|
+
def __str__(self) -> str:
|
|
50
|
+
"""Return human readable string."""
|
|
51
|
+
return '<{} scene_id="{}" session_id="{}" originator="{}" velocity="{}"/>'.format(
|
|
52
|
+
type(self).__name__, self.scene_id, self.session_id, self.originator, self.velocity
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class ActivateSceneConfirmationStatus(Enum):
|
|
57
|
+
"""Enum class for status of command send confirmation."""
|
|
58
|
+
|
|
59
|
+
ACCEPTED = 0
|
|
60
|
+
ERROR_INVALID_PARAMETER = 1
|
|
61
|
+
ERROR_REQUEST_REJECTED = 2
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class FrameActivateSceneConfirmation(FrameBase):
|
|
65
|
+
"""Frame for confirmation of command send frame."""
|
|
66
|
+
|
|
67
|
+
PAYLOAD_LEN = 3
|
|
68
|
+
|
|
69
|
+
def __init__(self, session_id: Optional[int] = None, status: Optional[ActivateSceneConfirmationStatus] = None):
|
|
70
|
+
"""Init Frame."""
|
|
71
|
+
super().__init__(Command.GW_ACTIVATE_SCENE_CFM)
|
|
72
|
+
self.session_id = session_id
|
|
73
|
+
self.status = status
|
|
74
|
+
|
|
75
|
+
def get_payload(self) -> bytes:
|
|
76
|
+
"""Return Payload."""
|
|
77
|
+
assert self.status is not None
|
|
78
|
+
assert self.session_id is not None
|
|
79
|
+
ret = bytes([self.status.value])
|
|
80
|
+
ret += bytes([self.session_id >> 8 & 255, self.session_id & 255])
|
|
81
|
+
return ret
|
|
82
|
+
|
|
83
|
+
def from_payload(self, payload: bytes) -> None:
|
|
84
|
+
"""Init frame from binary data."""
|
|
85
|
+
self.status = ActivateSceneConfirmationStatus(payload[0])
|
|
86
|
+
self.session_id = payload[1] * 256 + payload[2]
|
|
87
|
+
|
|
88
|
+
def __str__(self) -> str:
|
|
89
|
+
"""Return human readable string."""
|
|
90
|
+
return '<{} session_id="{}" status="{}"/>'.format(
|
|
91
|
+
type(self).__name__, self.session_id, self.status
|
|
92
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Module for error notification."""
|
|
2
|
+
from pyvlx.const import Command
|
|
3
|
+
|
|
4
|
+
from .frame import FrameBase
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class FrameActivationLogUpdatedNotification(FrameBase):
|
|
8
|
+
"""Frame for error notification."""
|
|
9
|
+
|
|
10
|
+
PAYLOAD_LEN = 0
|
|
11
|
+
|
|
12
|
+
def __init__(self) -> None:
|
|
13
|
+
"""Init Frame."""
|
|
14
|
+
super().__init__(Command.GW_ACTIVATION_LOG_UPDATED_NTF)
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"""Module for sending command to gw."""
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
|
|
5
|
+
from pyvlx.const import Command, Originator, Priority
|
|
6
|
+
from pyvlx.exception import PyVLXException
|
|
7
|
+
from pyvlx.parameter import Parameter, Position
|
|
8
|
+
|
|
9
|
+
from .frame import FrameBase
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FrameCommandSendRequest(FrameBase):
|
|
13
|
+
"""Frame for sending command to gw."""
|
|
14
|
+
|
|
15
|
+
PAYLOAD_LEN = 66
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
node_ids: Optional[List[int]] = None,
|
|
20
|
+
parameter: Parameter = Parameter(),
|
|
21
|
+
active_parameter: int = 0,
|
|
22
|
+
session_id: Optional[int] = None,
|
|
23
|
+
originator: Originator = Originator.USER,
|
|
24
|
+
**functional_parameter: bytes
|
|
25
|
+
):
|
|
26
|
+
"""Init Frame."""
|
|
27
|
+
super().__init__(Command.GW_COMMAND_SEND_REQ)
|
|
28
|
+
self.node_ids = node_ids if node_ids is not None else []
|
|
29
|
+
self.parameter = parameter
|
|
30
|
+
self.active_parameter = active_parameter
|
|
31
|
+
self.fpi1 = 0
|
|
32
|
+
self.fpi2 = 0
|
|
33
|
+
self.functional_parameter = {}
|
|
34
|
+
self.session_id = session_id
|
|
35
|
+
self.originator = originator
|
|
36
|
+
self.priority = Priority.USER_LEVEL_2
|
|
37
|
+
"""Set the functional parameter indicator bytes in order to show which functional
|
|
38
|
+
parameters are included in the frame. Functional parameter dictionary will be checked
|
|
39
|
+
for keys 'fp1' to 'fp16' to set the appropriate indicator and the corresponding
|
|
40
|
+
self.functional_parameter."""
|
|
41
|
+
for i in range(1, 17):
|
|
42
|
+
key = "fp%s" % (i)
|
|
43
|
+
if key in functional_parameter:
|
|
44
|
+
self.functional_parameter[key] = functional_parameter[key]
|
|
45
|
+
if i < 9:
|
|
46
|
+
self.fpi1 += 2 ** (8 - i)
|
|
47
|
+
if i >= 9:
|
|
48
|
+
self.fpi2 += 2 ** (16 - i)
|
|
49
|
+
else:
|
|
50
|
+
self.functional_parameter[key] = bytes(2)
|
|
51
|
+
|
|
52
|
+
def get_payload(self) -> bytes:
|
|
53
|
+
"""Return Payload."""
|
|
54
|
+
# Session id
|
|
55
|
+
assert self.session_id is not None
|
|
56
|
+
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
|
|
57
|
+
ret += bytes([self.originator.value])
|
|
58
|
+
ret += bytes([self.priority.value])
|
|
59
|
+
ret += bytes(
|
|
60
|
+
[self.active_parameter]
|
|
61
|
+
) # ParameterActive pointing to main parameter (MP)
|
|
62
|
+
# FPI 1+2
|
|
63
|
+
ret += bytes([self.fpi1])
|
|
64
|
+
ret += bytes([self.fpi2])
|
|
65
|
+
# Main parameter + functional parameter fp1 to fp3
|
|
66
|
+
ret += bytes(self.parameter)
|
|
67
|
+
ret += bytes(self.functional_parameter["fp1"])
|
|
68
|
+
ret += bytes(self.functional_parameter["fp2"])
|
|
69
|
+
ret += bytes(self.functional_parameter["fp3"])
|
|
70
|
+
# Functional parameter fp4 to fp16
|
|
71
|
+
ret += bytes(26)
|
|
72
|
+
|
|
73
|
+
# Nodes array: Number of nodes + node array + padding
|
|
74
|
+
ret += bytes([len(self.node_ids)]) # index array count
|
|
75
|
+
ret += bytes(self.node_ids) + bytes(20 - len(self.node_ids))
|
|
76
|
+
|
|
77
|
+
# Priority Level Lock
|
|
78
|
+
ret += bytes([0])
|
|
79
|
+
# Priority Level information 1+2
|
|
80
|
+
ret += bytes([0, 0])
|
|
81
|
+
# Locktime
|
|
82
|
+
ret += bytes([0])
|
|
83
|
+
return ret
|
|
84
|
+
|
|
85
|
+
def from_payload(self, payload: bytes) -> None:
|
|
86
|
+
"""Init frame from binary data."""
|
|
87
|
+
self.session_id = payload[0] * 256 + payload[1]
|
|
88
|
+
self.originator = Originator(payload[2])
|
|
89
|
+
self.priority = Priority(payload[3])
|
|
90
|
+
|
|
91
|
+
len_node_ids = payload[41]
|
|
92
|
+
if len_node_ids > 20:
|
|
93
|
+
raise PyVLXException("command_send_request_wrong_node_length")
|
|
94
|
+
self.node_ids = []
|
|
95
|
+
for i in range(len_node_ids):
|
|
96
|
+
self.node_ids.append(payload[42] + i)
|
|
97
|
+
|
|
98
|
+
self.parameter = Parameter(payload[7:9])
|
|
99
|
+
|
|
100
|
+
def __str__(self) -> str:
|
|
101
|
+
"""Return human readable string."""
|
|
102
|
+
functional_parameter = ""
|
|
103
|
+
for key, value in self.functional_parameter.items():
|
|
104
|
+
functional_parameter += "%s: %s, " % (
|
|
105
|
+
str(key),
|
|
106
|
+
Position(Parameter(bytes(value))),
|
|
107
|
+
)
|
|
108
|
+
return (
|
|
109
|
+
'<{} node_ids="{}" active_parameter="{}" parameter="{}" functional_parameter="{}" '
|
|
110
|
+
'session_id="{}" originator="{}"/>'.format(
|
|
111
|
+
type(self).__name__, self.node_ids, self.active_parameter,
|
|
112
|
+
self.parameter, functional_parameter,
|
|
113
|
+
self.session_id, self.originator,
|
|
114
|
+
)
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class CommandSendConfirmationStatus(Enum):
|
|
119
|
+
"""Enum class for status of command send confirmation."""
|
|
120
|
+
|
|
121
|
+
REJECTED = 0
|
|
122
|
+
ACCEPTED = 1
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class FrameCommandSendConfirmation(FrameBase):
|
|
126
|
+
"""Frame for confirmation of command send frame."""
|
|
127
|
+
|
|
128
|
+
PAYLOAD_LEN = 3
|
|
129
|
+
|
|
130
|
+
def __init__(self, session_id: Optional[int] = None, status: Optional[CommandSendConfirmationStatus] = None):
|
|
131
|
+
"""Init Frame."""
|
|
132
|
+
super().__init__(Command.GW_COMMAND_SEND_CFM)
|
|
133
|
+
self.session_id = session_id
|
|
134
|
+
self.status = status
|
|
135
|
+
|
|
136
|
+
def get_payload(self) -> bytes:
|
|
137
|
+
"""Return Payload."""
|
|
138
|
+
assert self.session_id is not None
|
|
139
|
+
assert self.status is not None
|
|
140
|
+
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
|
|
141
|
+
ret += bytes([self.status.value])
|
|
142
|
+
return ret
|
|
143
|
+
|
|
144
|
+
def from_payload(self, payload: bytes) -> None:
|
|
145
|
+
"""Init frame from binary data."""
|
|
146
|
+
self.session_id = payload[0] * 256 + payload[1]
|
|
147
|
+
self.status = CommandSendConfirmationStatus(payload[2])
|
|
148
|
+
|
|
149
|
+
def __str__(self) -> str:
|
|
150
|
+
"""Return human readable string."""
|
|
151
|
+
return '<{} session_id="{}" status="{}"/>'.format(
|
|
152
|
+
type(self).__name__, self.session_id, self.status
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class FrameCommandRunStatusNotification(FrameBase):
|
|
157
|
+
"""Frame for run status notification in scope of command send frame."""
|
|
158
|
+
|
|
159
|
+
PAYLOAD_LEN = 13
|
|
160
|
+
|
|
161
|
+
def __init__(
|
|
162
|
+
self,
|
|
163
|
+
session_id: Optional[int] = None,
|
|
164
|
+
status_id: Optional[int] = None,
|
|
165
|
+
index_id: Optional[int] = None,
|
|
166
|
+
node_parameter: Optional[int] = None,
|
|
167
|
+
parameter_value: Optional[int] = None,
|
|
168
|
+
):
|
|
169
|
+
"""Init Frame."""
|
|
170
|
+
super().__init__(Command.GW_COMMAND_RUN_STATUS_NTF)
|
|
171
|
+
self.session_id = session_id
|
|
172
|
+
self.status_id = status_id
|
|
173
|
+
self.index_id = index_id
|
|
174
|
+
self.node_parameter = node_parameter
|
|
175
|
+
self.parameter_value = parameter_value
|
|
176
|
+
|
|
177
|
+
def get_payload(self) -> bytes:
|
|
178
|
+
"""Return Payload."""
|
|
179
|
+
assert self.session_id is not None
|
|
180
|
+
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
|
|
181
|
+
assert self.status_id is not None
|
|
182
|
+
ret += bytes([self.status_id])
|
|
183
|
+
assert self.index_id is not None
|
|
184
|
+
ret += bytes([self.index_id])
|
|
185
|
+
assert self.node_parameter is not None
|
|
186
|
+
ret += bytes([self.node_parameter])
|
|
187
|
+
assert self.parameter_value is not None
|
|
188
|
+
ret += bytes([self.parameter_value >> 8 & 255, self.parameter_value & 255])
|
|
189
|
+
|
|
190
|
+
# XXX: Missing implementation of run_status, status_reply and information_code
|
|
191
|
+
ret += bytes(6)
|
|
192
|
+
return ret
|
|
193
|
+
|
|
194
|
+
def from_payload(self, payload: bytes) -> None:
|
|
195
|
+
"""Init frame from binary data."""
|
|
196
|
+
self.session_id = payload[0] * 256 + payload[1]
|
|
197
|
+
self.status_id = payload[2]
|
|
198
|
+
self.index_id = payload[3]
|
|
199
|
+
self.node_parameter = payload[4]
|
|
200
|
+
self.parameter_value = payload[5] * 256 + payload[6]
|
|
201
|
+
|
|
202
|
+
def __str__(self) -> str:
|
|
203
|
+
"""Return human readable string."""
|
|
204
|
+
return (
|
|
205
|
+
'<{} session_id="{}" status_id="{}" '
|
|
206
|
+
'index_id="{}" node_parameter="{}" parameter_value="{}"/>'.format(
|
|
207
|
+
type(self).__name__, self.session_id,
|
|
208
|
+
self.status_id, self.index_id,
|
|
209
|
+
self.node_parameter, self.parameter_value
|
|
210
|
+
)
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class FrameCommandRemainingTimeNotification(FrameBase):
|
|
215
|
+
"""Frame for notification of remaining time in scope of command send frame."""
|
|
216
|
+
|
|
217
|
+
PAYLOAD_LEN = 6
|
|
218
|
+
|
|
219
|
+
def __init__(self, session_id: Optional[int] = None, index_id: Optional[int] = None, node_parameter: Optional[int] = None, seconds: int = 0):
|
|
220
|
+
"""Init Frame."""
|
|
221
|
+
super().__init__(Command.GW_COMMAND_REMAINING_TIME_NTF)
|
|
222
|
+
self.session_id = session_id
|
|
223
|
+
self.index_id = index_id
|
|
224
|
+
self.node_parameter = node_parameter
|
|
225
|
+
self.seconds = seconds
|
|
226
|
+
|
|
227
|
+
def get_payload(self) -> bytes:
|
|
228
|
+
"""Return Payload."""
|
|
229
|
+
assert self.session_id is not None
|
|
230
|
+
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
|
|
231
|
+
assert self.index_id is not None
|
|
232
|
+
ret += bytes([self.index_id])
|
|
233
|
+
assert self.node_parameter is not None
|
|
234
|
+
ret += bytes([self.node_parameter])
|
|
235
|
+
ret += bytes([self.seconds >> 8 & 255, self.seconds & 255])
|
|
236
|
+
return ret
|
|
237
|
+
|
|
238
|
+
def from_payload(self, payload: bytes) -> None:
|
|
239
|
+
"""Init frame from binary data."""
|
|
240
|
+
self.session_id = payload[0] * 256 + payload[1]
|
|
241
|
+
self.index_id = payload[2]
|
|
242
|
+
self.node_parameter = payload[3]
|
|
243
|
+
self.seconds = payload[4] * 256 + payload[5]
|
|
244
|
+
|
|
245
|
+
def __str__(self) -> str:
|
|
246
|
+
"""Return human readable string."""
|
|
247
|
+
return (
|
|
248
|
+
'<{} session_id="{}" index_id="{}" '
|
|
249
|
+
'node_parameter="{}" seconds="{}"/>'.format(
|
|
250
|
+
type(self).__name__, self.session_id,
|
|
251
|
+
self.index_id, self.node_parameter, self.seconds
|
|
252
|
+
)
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
class FrameSessionFinishedNotification(FrameBase):
|
|
257
|
+
"""Frame for notification of session finishid in scope of command send frame."""
|
|
258
|
+
|
|
259
|
+
PAYLOAD_LEN = 2
|
|
260
|
+
|
|
261
|
+
def __init__(self, session_id: Optional[int] = None):
|
|
262
|
+
"""Init Frame."""
|
|
263
|
+
super().__init__(Command.GW_SESSION_FINISHED_NTF)
|
|
264
|
+
self.session_id = session_id
|
|
265
|
+
|
|
266
|
+
def get_payload(self) -> bytes:
|
|
267
|
+
"""Return Payload."""
|
|
268
|
+
assert self.session_id is not None
|
|
269
|
+
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
|
|
270
|
+
return ret
|
|
271
|
+
|
|
272
|
+
def from_payload(self, payload: bytes) -> None:
|
|
273
|
+
"""Init frame from binary data."""
|
|
274
|
+
self.session_id = payload[0] * 256 + payload[1]
|
|
275
|
+
|
|
276
|
+
def __str__(self) -> str:
|
|
277
|
+
"""Return human readable string."""
|
|
278
|
+
return '<{} session_id="{}"/>'.format(
|
|
279
|
+
type(self).__name__, self.session_id
|
|
280
|
+
)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Module for discover nodes requests."""
|
|
2
|
+
from pyvlx.const import Command, NodeType
|
|
3
|
+
|
|
4
|
+
from .frame import FrameBase
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class FrameDiscoverNodesRequest(FrameBase):
|
|
8
|
+
"""Frame for discover nodes request."""
|
|
9
|
+
|
|
10
|
+
PAYLOAD_LEN = 1
|
|
11
|
+
|
|
12
|
+
def __init__(self, node_type: NodeType = NodeType.NO_TYPE):
|
|
13
|
+
"""Init Frame."""
|
|
14
|
+
super().__init__(Command.GW_CS_DISCOVER_NODES_REQ)
|
|
15
|
+
self.node_type = node_type
|
|
16
|
+
|
|
17
|
+
def get_payload(self) -> bytes:
|
|
18
|
+
"""Return Payload."""
|
|
19
|
+
ret = bytes([self.node_type.value])
|
|
20
|
+
return ret
|
|
21
|
+
|
|
22
|
+
def from_payload(self, payload: bytes) -> None:
|
|
23
|
+
"""Init frame from binary data."""
|
|
24
|
+
self.node_type = NodeType(payload[0])
|
|
25
|
+
|
|
26
|
+
def __str__(self) -> str:
|
|
27
|
+
"""Return human readable string."""
|
|
28
|
+
return '<{} node_type="{}"/>'.format(type(self).__name__, self.node_type)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class FrameDiscoverNodesConfirmation(FrameBase):
|
|
32
|
+
"""Frame for discover nodes confirmation."""
|
|
33
|
+
|
|
34
|
+
PAYLOAD_LEN = 0
|
|
35
|
+
|
|
36
|
+
def __init__(self) -> None:
|
|
37
|
+
"""Init Frame."""
|
|
38
|
+
super().__init__(Command.GW_CS_DISCOVER_NODES_CFM)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class FrameDiscoverNodesNotification(FrameBase):
|
|
42
|
+
"""Frame for discover nodes notification."""
|
|
43
|
+
|
|
44
|
+
PAYLOAD_LEN = 131
|
|
45
|
+
|
|
46
|
+
def __init__(self) -> None:
|
|
47
|
+
"""Init Frame."""
|
|
48
|
+
super().__init__(Command.GW_CS_DISCOVER_NODES_NTF)
|
|
49
|
+
self.payload = b"\0" * 131
|
|
50
|
+
|
|
51
|
+
def get_payload(self) -> bytes:
|
|
52
|
+
"""Return Payload."""
|
|
53
|
+
return self.payload
|
|
54
|
+
|
|
55
|
+
def from_payload(self, payload: bytes) -> None:
|
|
56
|
+
"""Init frame from binary data."""
|
|
57
|
+
self.payload = payload
|
|
58
|
+
|
|
59
|
+
def __str__(self) -> str:
|
|
60
|
+
"""Return human readable string."""
|
|
61
|
+
return '<{} payload="{}"/>'.format(
|
|
62
|
+
type(self).__name__,
|
|
63
|
+
':'.join('{:02x}'.format(c) for c in self.payload)
|
|
64
|
+
)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Module for error notification."""
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
from pyvlx.const import Command
|
|
5
|
+
|
|
6
|
+
from .frame import FrameBase
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ErrorType(Enum):
|
|
10
|
+
# pylint: disable=invalid-name
|
|
11
|
+
"""Enum class for error types."""
|
|
12
|
+
|
|
13
|
+
NotFurtherDefined = 0
|
|
14
|
+
UnknownCommand = 1
|
|
15
|
+
ErrorOnFrameStructure = 2
|
|
16
|
+
BusBusy = 7
|
|
17
|
+
BadSystemTableIndex = 8
|
|
18
|
+
NotAuthenticated = 12
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class FrameErrorNotification(FrameBase):
|
|
22
|
+
"""Frame for error notification."""
|
|
23
|
+
|
|
24
|
+
PAYLOAD_LEN = 1
|
|
25
|
+
|
|
26
|
+
def __init__(self, error_type: ErrorType = ErrorType.NotFurtherDefined):
|
|
27
|
+
"""Init Frame."""
|
|
28
|
+
super().__init__(Command.GW_ERROR_NTF)
|
|
29
|
+
self.error_type = error_type
|
|
30
|
+
|
|
31
|
+
def get_payload(self) -> bytes:
|
|
32
|
+
"""Return Payload."""
|
|
33
|
+
ret = bytes([self.error_type.value])
|
|
34
|
+
return ret
|
|
35
|
+
|
|
36
|
+
def from_payload(self, payload: bytes) -> None:
|
|
37
|
+
"""Init frame from binary data."""
|
|
38
|
+
self.error_type = ErrorType(payload[0])
|
|
39
|
+
|
|
40
|
+
def __str__(self) -> str:
|
|
41
|
+
"""Return human readable string."""
|
|
42
|
+
return '<{} error_type="{}"/>'.format(type(self).__name__, self.error_type)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Module for reboot frame classes."""
|
|
2
|
+
from pyvlx.const import Command
|
|
3
|
+
|
|
4
|
+
from .frame import FrameBase
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class FrameGatewayFactoryDefaultRequest(FrameBase):
|
|
8
|
+
"""Frame for requesting factory reset."""
|
|
9
|
+
|
|
10
|
+
PAYLOAD_LEN = 0
|
|
11
|
+
|
|
12
|
+
def __init__(self) -> None:
|
|
13
|
+
"""Init Frame."""
|
|
14
|
+
super().__init__(Command.GW_SET_FACTORY_DEFAULT_REQ)
|
|
15
|
+
|
|
16
|
+
def __str__(self) -> str:
|
|
17
|
+
"""Return human readable string."""
|
|
18
|
+
return '<{}/>'.format(type(self).__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class FrameGatewayFactoryDefaultConfirmation(FrameBase):
|
|
22
|
+
"""Frame for response for factory reset."""
|
|
23
|
+
|
|
24
|
+
PAYLOAD_LEN = 0
|
|
25
|
+
|
|
26
|
+
def __init__(self) -> None:
|
|
27
|
+
"""Init Frame."""
|
|
28
|
+
super().__init__(Command.GW_SET_FACTORY_DEFAULT_CFM)
|
|
29
|
+
|
|
30
|
+
def __str__(self) -> str:
|
|
31
|
+
"""Return human readable string."""
|
|
32
|
+
return '<{}/>'.format(type(self).__name__)
|