velbus-aio 2021.8.7__py3-none-any.whl → 2025.11.0__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.
- scripts/parse_specs.py +156 -0
- velbus_aio-2025.11.0.dist-info/METADATA +71 -0
- velbus_aio-2025.11.0.dist-info/RECORD +194 -0
- {velbus_aio-2021.8.7.dist-info → velbus_aio-2025.11.0.dist-info}/WHEEL +1 -1
- velbus_aio-2025.11.0.dist-info/top_level.txt +3 -0
- velbusaio/channels.py +443 -109
- velbusaio/command_registry.py +126 -13
- velbusaio/const.py +36 -12
- velbusaio/controller.py +252 -177
- velbusaio/discovery.py +2 -2
- velbusaio/exceptions.py +22 -0
- velbusaio/handler.py +311 -145
- velbusaio/helpers.py +6 -18
- velbusaio/message.py +46 -132
- velbusaio/messages/__init__.py +12 -2
- velbusaio/messages/blind_status.py +16 -25
- velbusaio/messages/bus_active.py +3 -9
- velbusaio/messages/bus_error_counter_status.py +3 -4
- velbusaio/messages/bus_error_counter_status_request.py +3 -4
- velbusaio/messages/bus_off.py +3 -4
- velbusaio/messages/channel_name_part1.py +49 -33
- velbusaio/messages/channel_name_part2.py +49 -33
- velbusaio/messages/channel_name_part3.py +49 -33
- velbusaio/messages/channel_name_request.py +26 -12
- velbusaio/messages/clear_led.py +3 -4
- velbusaio/messages/counter_status.py +3 -17
- velbusaio/messages/counter_status_request.py +6 -6
- velbusaio/messages/counter_value.py +44 -0
- velbusaio/messages/cover_down.py +4 -29
- velbusaio/messages/cover_off.py +5 -29
- velbusaio/messages/cover_position.py +4 -19
- velbusaio/messages/cover_up.py +4 -27
- velbusaio/messages/dali_device_settings.py +178 -0
- velbusaio/messages/dali_device_settings_request.py +53 -0
- velbusaio/messages/dali_dim_value_status.py +44 -0
- velbusaio/messages/dimmer_channel_status.py +6 -19
- velbusaio/messages/dimmer_status.py +14 -31
- velbusaio/messages/edge_set_color.py +114 -0
- velbusaio/messages/edge_set_custom_color.py +56 -0
- velbusaio/messages/fast_blinking_led.py +3 -4
- velbusaio/messages/forced_off.py +3 -4
- velbusaio/messages/forced_on.py +3 -4
- velbusaio/messages/interface_status_request.py +3 -4
- velbusaio/messages/ir_receiver_status.py +18 -0
- velbusaio/messages/kwh_status.py +3 -19
- velbusaio/messages/light_value_request.py +3 -4
- velbusaio/messages/memo_text.py +3 -5
- velbusaio/messages/memory_data.py +3 -16
- velbusaio/messages/memory_data_block.py +3 -4
- velbusaio/messages/memory_dump_request.py +3 -4
- velbusaio/messages/module_status.py +107 -55
- velbusaio/messages/module_status_request.py +7 -6
- velbusaio/messages/module_subtype.py +11 -19
- velbusaio/messages/module_type.py +132 -21
- velbusaio/messages/module_type_request.py +1 -0
- velbusaio/messages/psu_load.py +56 -0
- velbusaio/messages/psu_values.py +53 -0
- velbusaio/messages/push_button_status.py +3 -16
- velbusaio/messages/raw.py +74 -0
- velbusaio/messages/read_data_block_from_memory.py +3 -4
- velbusaio/messages/read_data_from_memory.py +3 -4
- velbusaio/messages/realtime_clock_status_request.py +3 -4
- velbusaio/messages/receive_buffer_full.py +3 -4
- velbusaio/messages/receive_ready.py +3 -4
- velbusaio/messages/relay_status.py +13 -42
- velbusaio/messages/restore_dimmer.py +33 -24
- velbusaio/messages/select_program.py +35 -0
- velbusaio/messages/sensor_settings_request.py +3 -4
- velbusaio/messages/sensor_temp_request.py +3 -4
- velbusaio/messages/sensor_temperature.py +15 -19
- velbusaio/messages/set_date.py +10 -30
- velbusaio/messages/set_daylight_saving.py +8 -24
- velbusaio/messages/set_dimmer.py +43 -41
- velbusaio/messages/set_led.py +3 -4
- velbusaio/messages/set_realtime_clock.py +10 -30
- velbusaio/messages/set_temperature.py +3 -4
- velbusaio/messages/slider_status.py +16 -20
- velbusaio/messages/slow_blinking_led.py +3 -4
- velbusaio/messages/start_relay_blinking_timer.py +3 -4
- velbusaio/messages/start_relay_timer.py +3 -4
- velbusaio/messages/switch_relay_off.py +3 -16
- velbusaio/messages/switch_relay_on.py +3 -16
- velbusaio/messages/switch_to_comfort.py +4 -15
- velbusaio/messages/switch_to_day.py +4 -15
- velbusaio/messages/switch_to_night.py +4 -15
- velbusaio/messages/switch_to_safe.py +4 -15
- velbusaio/messages/temp_sensor_settings_part1.py +3 -4
- velbusaio/messages/temp_sensor_settings_part2.py +27 -0
- velbusaio/messages/temp_sensor_settings_part3.py +27 -0
- velbusaio/messages/temp_sensor_settings_part4.py +27 -0
- velbusaio/messages/temp_sensor_settings_request.py +3 -4
- velbusaio/messages/temp_sensor_status.py +34 -35
- velbusaio/messages/temp_set_cooling.py +3 -13
- velbusaio/messages/temp_set_heating.py +3 -13
- velbusaio/messages/update_led_status.py +3 -4
- velbusaio/messages/very_fast_blinking_led.py +3 -4
- velbusaio/messages/write_data_to_memory.py +3 -4
- velbusaio/messages/write_memory_block.py +3 -4
- velbusaio/messages/write_module_address_and_serial_number.py +3 -4
- velbusaio/module.py +680 -158
- velbusaio/module_spec/01.json +62 -0
- velbusaio/module_spec/02.json +16 -0
- velbusaio/module_spec/03.json +23 -0
- velbusaio/module_spec/04.json +283 -0
- velbusaio/module_spec/05.json +54 -0
- velbusaio/module_spec/06.json +110 -0
- velbusaio/module_spec/07.json +16 -0
- velbusaio/module_spec/08.json +38 -0
- velbusaio/module_spec/09.json +30 -0
- velbusaio/module_spec/0A.json +58 -0
- velbusaio/module_spec/0B.json +58 -0
- velbusaio/module_spec/0C.json +18 -0
- velbusaio/module_spec/0E.json +25 -0
- velbusaio/module_spec/0F.json +16 -0
- velbusaio/module_spec/10.json +111 -0
- velbusaio/module_spec/11.json +111 -0
- velbusaio/module_spec/12.json +73 -0
- velbusaio/module_spec/13.json +4 -0
- velbusaio/module_spec/14.json +16 -0
- velbusaio/module_spec/15.json +83 -0
- velbusaio/module_spec/16.json +129 -0
- velbusaio/module_spec/17.json +129 -0
- velbusaio/module_spec/18.json +129 -0
- velbusaio/module_spec/1A.json +79 -0
- velbusaio/module_spec/1B.json +107 -0
- velbusaio/module_spec/1D.json +89 -0
- velbusaio/module_spec/1E.json +306 -0
- velbusaio/module_spec/1F.json +178 -0
- velbusaio/module_spec/20.json +178 -0
- velbusaio/module_spec/21.json +326 -0
- velbusaio/module_spec/22.json +426 -0
- velbusaio/module_spec/23.json +129 -0
- velbusaio/module_spec/24.json +30 -0
- velbusaio/module_spec/25.json +3 -0
- velbusaio/module_spec/28.json +454 -0
- velbusaio/module_spec/29.json +235 -0
- velbusaio/module_spec/2A.json +239 -0
- velbusaio/module_spec/2B.json +239 -0
- velbusaio/module_spec/2C.json +257 -0
- velbusaio/module_spec/2D.json +270 -0
- velbusaio/module_spec/2E.json +215 -0
- velbusaio/module_spec/2F.json +211 -0
- velbusaio/module_spec/30.json +58 -0
- velbusaio/module_spec/31.json +465 -0
- velbusaio/module_spec/32.json +385 -0
- velbusaio/module_spec/33.json +249 -0
- velbusaio/module_spec/34.json +313 -0
- velbusaio/module_spec/35.json +313 -0
- velbusaio/module_spec/36.json +313 -0
- velbusaio/module_spec/37.json +333 -0
- velbusaio/module_spec/38.json +111 -0
- velbusaio/module_spec/39.json +4 -0
- velbusaio/module_spec/3A.json +306 -0
- velbusaio/module_spec/3B.json +306 -0
- velbusaio/module_spec/3C.json +306 -0
- velbusaio/module_spec/3D.json +454 -0
- velbusaio/module_spec/3E.json +302 -0
- velbusaio/module_spec/3F.json +4 -0
- velbusaio/module_spec/40.json +4 -0
- velbusaio/module_spec/41.json +241 -0
- velbusaio/module_spec/42.json +4 -0
- velbusaio/module_spec/43.json +23 -0
- velbusaio/module_spec/44.json +38 -0
- velbusaio/module_spec/45.json +4 -0
- velbusaio/module_spec/48.json +111 -0
- velbusaio/module_spec/49.json +111 -0
- velbusaio/module_spec/4A.json +89 -0
- velbusaio/module_spec/4B.json +138 -0
- velbusaio/module_spec/4C.json +129 -0
- velbusaio/module_spec/4D.json +108 -0
- velbusaio/module_spec/4E.json +787 -0
- velbusaio/module_spec/4F.json +114 -0
- velbusaio/module_spec/50.json +114 -0
- velbusaio/module_spec/51.json +114 -0
- velbusaio/module_spec/52.json +456 -0
- velbusaio/module_spec/54.json +270 -0
- velbusaio/module_spec/55.json +270 -0
- velbusaio/module_spec/56.json +270 -0
- velbusaio/module_spec/57.json +260 -0
- velbusaio/module_spec/5A.json +4 -0
- velbusaio/module_spec/5B.json +4 -0
- velbusaio/module_spec/5C.json +90 -0
- velbusaio/module_spec/5F.json +78 -0
- velbusaio/module_spec/60.json +4 -0
- velbusaio/module_spec/61.json +89 -0
- velbusaio/module_spec/broadcast.json +67 -0
- velbusaio/module_spec/ignore.json +22 -0
- velbusaio/protocol.py +243 -0
- velbusaio/py.typed +0 -0
- velbusaio/raw_message.py +149 -0
- velbusaio/util.py +55 -0
- velbusaio/vlp_reader.py +249 -0
- velbus_aio-2021.8.7.dist-info/METADATA +0 -66
- velbus_aio-2021.8.7.dist-info/RECORD +0 -90
- velbus_aio-2021.8.7.dist-info/top_level.txt +0 -1
- velbusaio/messages/meteo_raw.py +0 -52
- velbusaio/module_registry.py +0 -64
- velbusaio/moduleprotocol/protocol.json +0 -25540
- velbusaio/parser.py +0 -142
- {velbus_aio-2021.8.7.dist-info → velbus_aio-2025.11.0.dist-info/licenses}/LICENSE +0 -0
velbusaio/parser.py
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
:author: Maikel Punie <maikel.punie@gmail.com>
|
|
3
|
-
"""
|
|
4
|
-
from __future__ import annotations
|
|
5
|
-
|
|
6
|
-
import asyncio
|
|
7
|
-
import itertools
|
|
8
|
-
import logging
|
|
9
|
-
from collections import deque
|
|
10
|
-
|
|
11
|
-
from velbusaio.const import (
|
|
12
|
-
ETX,
|
|
13
|
-
HEADER_LENGTH,
|
|
14
|
-
LENGTH_MASK,
|
|
15
|
-
MAX_DATA_AMOUNT,
|
|
16
|
-
MIN_PACKET_LENGTH,
|
|
17
|
-
PRIORITIES,
|
|
18
|
-
STX,
|
|
19
|
-
)
|
|
20
|
-
from velbusaio.helpers import checksum
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class VelbusParser:
|
|
24
|
-
"""
|
|
25
|
-
Transform Velbus message from wire format to Message object
|
|
26
|
-
"""
|
|
27
|
-
|
|
28
|
-
def __init__(self):
|
|
29
|
-
super().__init__()
|
|
30
|
-
self.logger = logging.getLogger("velbus-parser")
|
|
31
|
-
self.buffer = deque(maxlen=10000)
|
|
32
|
-
|
|
33
|
-
def feed(self, data):
|
|
34
|
-
"""
|
|
35
|
-
Feed received data in the buffer
|
|
36
|
-
"""
|
|
37
|
-
self.buffer.extend(bytearray(data))
|
|
38
|
-
|
|
39
|
-
# async def _next(self):
|
|
40
|
-
# packet = None
|
|
41
|
-
# has_valid_packet = self._has_valid_packet_waiting()
|
|
42
|
-
# while not has_valid_packet:
|
|
43
|
-
# if len(self.buffer) > HEADER_LENGTH and self.__has_packet_length_waiting():
|
|
44
|
-
# self.__realign_buffer()
|
|
45
|
-
# has_valid_packet = self._has_valid_packet_waiting()
|
|
46
|
-
# await asyncio.sleep(1)
|
|
47
|
-
#
|
|
48
|
-
# if has_valid_packet:
|
|
49
|
-
# packet = self._extract_packet()
|
|
50
|
-
# return packet
|
|
51
|
-
|
|
52
|
-
async def wait_for_packet(self):
|
|
53
|
-
"""
|
|
54
|
-
Wait for a valid apcket
|
|
55
|
-
"""
|
|
56
|
-
while not self._has_valid_packet_waiting():
|
|
57
|
-
await asyncio.sleep(0.1)
|
|
58
|
-
return self._extract_packet()
|
|
59
|
-
|
|
60
|
-
def _has_valid_packet_waiting(self):
|
|
61
|
-
"""
|
|
62
|
-
Checks whether or not the parser has a valid packet in its buffer.
|
|
63
|
-
:return: A boolean indicating whether or not the parser has a valid packet in its buffer.
|
|
64
|
-
TODO Fix
|
|
65
|
-
"""
|
|
66
|
-
if not self.__has_valid_header_waiting():
|
|
67
|
-
return False
|
|
68
|
-
if len(self.buffer) < MIN_PACKET_LENGTH:
|
|
69
|
-
return False
|
|
70
|
-
return self.__has_packet_length_waiting() or False
|
|
71
|
-
# bytes_to_check = bytearray(
|
|
72
|
-
# itertools.islice(self.buffer, 0, 4 + self.__curr_packet_body_length())
|
|
73
|
-
# )
|
|
74
|
-
# checksum_valid = self.buffer[(self.__curr_packet_length() - 2)] == checksum(
|
|
75
|
-
# bytes_to_check
|
|
76
|
-
# )
|
|
77
|
-
# end_valid = self.buffer[(self.__curr_packet_length() - 1)] == ETX
|
|
78
|
-
# return checksum_valid and end_valid
|
|
79
|
-
|
|
80
|
-
def __has_valid_header_waiting(self):
|
|
81
|
-
"""
|
|
82
|
-
Checks whether or not the parser has a valid packet header waiting.
|
|
83
|
-
:return: A boolean indicating whether or not the parser has a valid packet header waiting.
|
|
84
|
-
"""
|
|
85
|
-
if len(self.buffer) < HEADER_LENGTH:
|
|
86
|
-
return False
|
|
87
|
-
start_valid = self.buffer[0] == STX
|
|
88
|
-
bodysize_valid = self.__curr_packet_body_length() <= MAX_DATA_AMOUNT
|
|
89
|
-
priority_valid = self.buffer[1] in PRIORITIES
|
|
90
|
-
return start_valid and bodysize_valid and priority_valid
|
|
91
|
-
|
|
92
|
-
def __has_packet_length_waiting(self):
|
|
93
|
-
"""
|
|
94
|
-
Checks whether the current packet has the full length's worth of data waiting in the buffer.
|
|
95
|
-
This should only be called when __has_valid_header_waiting() returns True.
|
|
96
|
-
"""
|
|
97
|
-
return len(self.buffer) >= self.__curr_packet_length()
|
|
98
|
-
|
|
99
|
-
def __curr_packet_length(self):
|
|
100
|
-
"""
|
|
101
|
-
Gets the current waiting packet's total length.
|
|
102
|
-
This should only be called when __has_valid_header_waiting() returns True.
|
|
103
|
-
:return: The current waiting packet's total length.
|
|
104
|
-
"""
|
|
105
|
-
return MIN_PACKET_LENGTH + self.__curr_packet_body_length()
|
|
106
|
-
|
|
107
|
-
def __curr_packet_body_length(self):
|
|
108
|
-
"""
|
|
109
|
-
Gets the current waiting packet's body length.
|
|
110
|
-
This should only be called when __has_valid_header_waiting() returns True.
|
|
111
|
-
:return: The current waiting packet's body length.
|
|
112
|
-
"""
|
|
113
|
-
return self.buffer[3] & LENGTH_MASK
|
|
114
|
-
|
|
115
|
-
def _extract_packet(self):
|
|
116
|
-
"""
|
|
117
|
-
Extracts a packet from the buffer and shifts it.
|
|
118
|
-
Make sure this is only called after __has_valid_packet_waiting() return True.
|
|
119
|
-
:return: A bytearray with the currently waiting packet.
|
|
120
|
-
"""
|
|
121
|
-
length = self.__curr_packet_length()
|
|
122
|
-
packet = bytearray(itertools.islice(self.buffer, 0, length))
|
|
123
|
-
self.__shift_buffer(length)
|
|
124
|
-
return packet
|
|
125
|
-
|
|
126
|
-
def __realign_buffer(self):
|
|
127
|
-
"""
|
|
128
|
-
Realigns buffer by shifting the queue until the next STX or until the buffer runs out.
|
|
129
|
-
"""
|
|
130
|
-
amount = 1
|
|
131
|
-
while amount < len(self.buffer) and self.buffer[amount] != STX:
|
|
132
|
-
amount += 1
|
|
133
|
-
|
|
134
|
-
self.__shift_buffer(amount)
|
|
135
|
-
|
|
136
|
-
def __shift_buffer(self, amount):
|
|
137
|
-
"""
|
|
138
|
-
Shifts the buffer by the specified amount.
|
|
139
|
-
:param amount: The amount of bytes that the buffer needs to be shifted.
|
|
140
|
-
"""
|
|
141
|
-
for _ in itertools.repeat(None, amount):
|
|
142
|
-
self.buffer.popleft()
|
|
File without changes
|