velbus-aio 2023.12.0__py3-none-any.whl → 2024.4.1__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.

Potentially problematic release.


This version of velbus-aio might be problematic. Click here for more details.

Files changed (100) hide show
  1. {velbus_aio-2023.12.0.dist-info → velbus_aio-2024.4.1.dist-info}/METADATA +2 -1
  2. velbus_aio-2024.4.1.dist-info/RECORD +103 -0
  3. {velbus_aio-2023.12.0.dist-info → velbus_aio-2024.4.1.dist-info}/WHEEL +1 -1
  4. velbusaio/channels.py +7 -11
  5. velbusaio/command_registry.py +15 -1
  6. velbusaio/const.py +3 -1
  7. velbusaio/controller.py +39 -68
  8. velbusaio/handler.py +5 -61
  9. velbusaio/helpers.py +2 -1
  10. velbusaio/message.py +1 -1
  11. velbusaio/messages/__init__.py +1 -0
  12. velbusaio/messages/blind_status.py +1 -0
  13. velbusaio/messages/bus_active.py +1 -0
  14. velbusaio/messages/bus_error_counter_status.py +1 -0
  15. velbusaio/messages/bus_error_counter_status_request.py +1 -0
  16. velbusaio/messages/bus_off.py +1 -0
  17. velbusaio/messages/channel_name_part1.py +15 -0
  18. velbusaio/messages/channel_name_part2.py +14 -0
  19. velbusaio/messages/channel_name_part3.py +14 -0
  20. velbusaio/messages/channel_name_request.py +2 -1
  21. velbusaio/messages/clear_led.py +1 -0
  22. velbusaio/messages/counter_status.py +1 -0
  23. velbusaio/messages/counter_status_request.py +1 -0
  24. velbusaio/messages/cover_down.py +1 -0
  25. velbusaio/messages/cover_off.py +1 -2
  26. velbusaio/messages/cover_position.py +1 -2
  27. velbusaio/messages/cover_up.py +1 -0
  28. velbusaio/messages/dali_device_settings.py +2 -1
  29. velbusaio/messages/dali_device_settings_request.py +2 -1
  30. velbusaio/messages/dali_dim_value_status.py +2 -1
  31. velbusaio/messages/dimmer_channel_status.py +2 -1
  32. velbusaio/messages/dimmer_status.py +1 -0
  33. velbusaio/messages/edge_set_custom_color.py +1 -0
  34. velbusaio/messages/fast_blinking_led.py +1 -0
  35. velbusaio/messages/forced_off.py +1 -0
  36. velbusaio/messages/forced_on.py +1 -0
  37. velbusaio/messages/interface_status_request.py +1 -0
  38. velbusaio/messages/ir_receiver_status.py +1 -0
  39. velbusaio/messages/kwh_status.py +1 -0
  40. velbusaio/messages/light_value_request.py +1 -0
  41. velbusaio/messages/memo_text.py +1 -0
  42. velbusaio/messages/memory_data.py +1 -0
  43. velbusaio/messages/memory_data_block.py +1 -0
  44. velbusaio/messages/memory_dump_request.py +1 -0
  45. velbusaio/messages/module_status.py +12 -0
  46. velbusaio/messages/module_status_request.py +1 -0
  47. velbusaio/messages/module_subtype.py +1 -0
  48. velbusaio/messages/module_type.py +1 -0
  49. velbusaio/messages/module_type_request.py +1 -0
  50. velbusaio/messages/push_button_status.py +1 -0
  51. velbusaio/messages/raw.py +1 -0
  52. velbusaio/messages/read_data_block_from_memory.py +1 -0
  53. velbusaio/messages/read_data_from_memory.py +1 -0
  54. velbusaio/messages/realtime_clock_status_request.py +1 -0
  55. velbusaio/messages/receive_buffer_full.py +1 -0
  56. velbusaio/messages/receive_ready.py +1 -0
  57. velbusaio/messages/relay_status.py +1 -0
  58. velbusaio/messages/restore_dimmer.py +6 -2
  59. velbusaio/messages/select_program.py +1 -0
  60. velbusaio/messages/sensor_settings_request.py +1 -0
  61. velbusaio/messages/sensor_temp_request.py +1 -0
  62. velbusaio/messages/sensor_temperature.py +1 -0
  63. velbusaio/messages/set_date.py +5 -10
  64. velbusaio/messages/set_daylight_saving.py +3 -6
  65. velbusaio/messages/set_dimmer.py +6 -2
  66. velbusaio/messages/set_led.py +1 -0
  67. velbusaio/messages/set_realtime_clock.py +5 -10
  68. velbusaio/messages/set_temperature.py +1 -0
  69. velbusaio/messages/slider_status.py +5 -1
  70. velbusaio/messages/slow_blinking_led.py +1 -0
  71. velbusaio/messages/start_relay_blinking_timer.py +1 -0
  72. velbusaio/messages/start_relay_timer.py +1 -0
  73. velbusaio/messages/switch_relay_off.py +1 -0
  74. velbusaio/messages/switch_relay_on.py +1 -0
  75. velbusaio/messages/switch_to_comfort.py +1 -0
  76. velbusaio/messages/switch_to_day.py +1 -0
  77. velbusaio/messages/switch_to_night.py +1 -0
  78. velbusaio/messages/switch_to_safe.py +1 -0
  79. velbusaio/messages/temp_sensor_settings_part1.py +1 -0
  80. velbusaio/messages/temp_sensor_settings_part2.py +1 -0
  81. velbusaio/messages/temp_sensor_settings_part3.py +1 -0
  82. velbusaio/messages/temp_sensor_settings_part4.py +1 -0
  83. velbusaio/messages/temp_sensor_settings_request.py +1 -0
  84. velbusaio/messages/temp_sensor_status.py +1 -0
  85. velbusaio/messages/temp_set_cooling.py +1 -0
  86. velbusaio/messages/temp_set_heating.py +1 -0
  87. velbusaio/messages/update_led_status.py +1 -0
  88. velbusaio/messages/very_fast_blinking_led.py +1 -0
  89. velbusaio/messages/write_data_to_memory.py +1 -0
  90. velbusaio/messages/write_memory_block.py +1 -0
  91. velbusaio/messages/write_module_address_and_serial_number.py +1 -0
  92. velbusaio/module.py +44 -43
  93. velbusaio/protocol.json +10126 -0
  94. velbusaio/protocol.py +2 -2
  95. velbusaio/raw_message.py +6 -6
  96. velbusaio/util.py +4 -0
  97. velbus_aio-2023.12.0.dist-info/RECORD +0 -103
  98. velbusaio/moduleprotocol/protocol.json +0 -26507
  99. {velbus_aio-2023.12.0.dist-info → velbus_aio-2024.4.1.dist-info}/LICENSE +0 -0
  100. {velbus_aio-2023.12.0.dist-info → velbus_aio-2024.4.1.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,9 +1,8 @@
1
1
  """
2
2
  :author: Maikel Punie <maikel.punie@gmail.com>
3
3
  """
4
- from __future__ import annotations
5
4
 
6
- import time
5
+ from __future__ import annotations
7
6
 
8
7
  from velbusaio.command_registry import register
9
8
  from velbusaio.message import Message
@@ -17,11 +16,11 @@ class SetRealtimeClock(Message):
17
16
  received by all modules
18
17
  """
19
18
 
20
- def __init__(self, address=0x00) -> None:
19
+ def __init__(self, address=0x00, wday=None, hour=None, min=None) -> None:
21
20
  Message.__init__(self)
22
- self._wday = None
23
- self._hour = None
24
- self._min = None
21
+ self._wday = wday
22
+ self._hour = hour
23
+ self._min = min
25
24
  self.set_defaults(address)
26
25
 
27
26
  def set_defaults(self, address) -> None:
@@ -29,10 +28,6 @@ class SetRealtimeClock(Message):
29
28
  self.set_address(address)
30
29
  self.set_low_priority()
31
30
  self.set_no_rtr()
32
- lclt = time.localtime()
33
- self._wday = lclt[6]
34
- self._hour = lclt[3]
35
- self._min = lclt[4]
36
31
 
37
32
  def populate(self, priority, address, rtr, data) -> None:
38
33
  """
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Maikel Punie <maikel.punie@gmail.com>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Frank van Breugel
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -9,7 +10,10 @@ from velbusaio.message import Message
9
10
  COMMAND_CODE = 0x0F
10
11
 
11
12
 
12
- @register(COMMAND_CODE, ["VMB1DM", "VMBDME", "VMB4DC", "VMBDMI", "VMBDMI-R", "VMB1LED"])
13
+ @register(
14
+ COMMAND_CODE,
15
+ ["VMB1DM", "VMBDME", "VMB4DC", "VMBDMI", "VMBDMI-R", "VMB1LED", "VMB8DC-20"],
16
+ )
13
17
  class SliderStatusMessage(Message):
14
18
  """
15
19
  sent by: VMBDME
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  import struct
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  import struct
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Maikel Punie <maikel.punie@gmail.com>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Danny De Gaspari
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Danny De Gaspari
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Danny De Gaspari
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Maikel Punie <maikel.punie@gmail.com>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Maikel Punie <maikel.punie@gmail.com>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  import json
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  from velbusaio.command_registry import register
@@ -1,6 +1,7 @@
1
1
  """
2
2
  :author: Thomas Delaet <thomas@delaet.org>
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  import struct
velbusaio/module.py CHANGED
@@ -1,14 +1,14 @@
1
1
  """
2
2
  This represents a velbus module
3
3
  """
4
+
4
5
  from __future__ import annotations
5
6
 
6
7
  import logging
7
- import os
8
8
  import pathlib
9
- import pickle
10
9
  import struct
11
10
  import sys
11
+ import json
12
12
  from typing import Awaitable, Callable
13
13
 
14
14
  from velbusaio.channels import (
@@ -36,7 +36,7 @@ from velbusaio.const import (
36
36
  )
37
37
  from velbusaio.helpers import handle_match, keys_exists
38
38
  from velbusaio.message import Message
39
- from velbusaio.messages import DaliDeviceSettingMsg
39
+ from velbusaio.messages.dali_device_settings import DaliDeviceSettingMsg
40
40
  from velbusaio.messages.blind_status import BlindStatusMessage, BlindStatusNgMessage
41
41
  from velbusaio.messages.channel_name_part1 import (
42
42
  ChannelNamePart1Message,
@@ -80,8 +80,6 @@ from velbusaio.messages.module_status import (
80
80
  ModuleStatusPirMessage,
81
81
  )
82
82
  from velbusaio.messages.module_status_request import ModuleStatusRequestMessage
83
- from velbusaio.messages.module_subtype import ModuleSubTypeMessage
84
- from velbusaio.messages.module_type import ModuleTypeMessage, ModuleType2Message
85
83
  from velbusaio.messages.push_button_status import PushButtonStatusMessage
86
84
  from velbusaio.messages.read_data_from_memory import ReadDataFromMemoryMessage
87
85
  from velbusaio.messages.relay_status import RelayStatusMessage, RelayStatusMessage2
@@ -111,7 +109,7 @@ class Module:
111
109
  build_week: int | None = None,
112
110
  cache_dir: str | None = None,
113
111
  ) -> Module:
114
- if module_type == 0x45:
112
+ if module_type == 0x45 or module_type == 0x5A:
115
113
  return VmbDali(
116
114
  module_address,
117
115
  module_type,
@@ -187,9 +185,9 @@ class Module:
187
185
  del self._channels[i]
188
186
 
189
187
  def _cache(self) -> None:
190
- cfile = pathlib.Path(f"{self._cache_dir}/{self._address}.p")
191
- with cfile.open("wb") as fl:
192
- pickle.dump(self, fl)
188
+ cfile = pathlib.Path(f"{self._cache_dir}/{self._address}.json")
189
+ with cfile.open("w") as fl:
190
+ json.dump(self.to_cache(), fl, indent=4)
193
191
 
194
192
  def __getstate__(self) -> dict:
195
193
  d = self.__dict__
@@ -200,20 +198,17 @@ class Module:
200
198
  self.__dict__ = state
201
199
 
202
200
  def __repr__(self) -> str:
203
- return (
204
- "<{}: {{{}}} @ {{{}}} loaded:{{{}}} loading:{{{}}} channels{{:{}}}>".format(
205
- self._name,
206
- self._type,
207
- self._address,
208
- self.loaded,
209
- self._is_loading,
210
- self._channels,
211
- )
212
- )
201
+ return f"<{self._name} type:{self._type} address:{self._address} loaded:{self.loaded} loading:{self._is_loading} channels: {self._channels}>"
213
202
 
214
203
  def __str__(self) -> str:
215
204
  return self.__repr__()
216
205
 
206
+ def to_cache(self) -> dict:
207
+ d = {"name": self._name, "channels": {}}
208
+ for num, chan in self._channels.items():
209
+ d["channels"][num] = chan.to_cache()
210
+ return d
211
+
217
212
  def get_addresses(self) -> list:
218
213
  """
219
214
  Get all addresses for this module
@@ -231,7 +226,9 @@ class Module:
231
226
  return self._type
232
227
 
233
228
  def get_type_name(self) -> str:
234
- return self._data["Type"]
229
+ if "Type" in self._data:
230
+ return self._data["Type"]
231
+ return "UNKNOWN"
235
232
 
236
233
  def get_serial(self) -> str | None:
237
234
  return self.serial
@@ -240,12 +237,7 @@ class Module:
240
237
  return self._name
241
238
 
242
239
  def get_sw_version(self) -> str:
243
- return "{}-{}.{}.{}".format(
244
- self.serial,
245
- self.memory_map_version,
246
- self.build_year,
247
- self.build_week,
248
- )
240
+ return f"{self.serial}-{self.memory_map_version}.{self.build_year}.{self.build_week}"
249
241
 
250
242
  def calc_channel_offset(self, address: int) -> int:
251
243
  _channel_offset = 0
@@ -548,14 +540,29 @@ class Module:
548
540
  self._log.info("Load Module")
549
541
  # start the loading
550
542
  self._is_loading = True
543
+ # see if we have a cache
544
+ try:
545
+ cfile = pathlib.Path(f"{self._cache_dir}/{self._address}.json")
546
+ with cfile.open("r") as fl:
547
+ cache = json.load(fl)
548
+ except OSError:
549
+ cache = {}
551
550
  # load default channels
552
551
  await self.__load_default_channels()
553
552
  # load the data from memory ( the stuff that we need)
554
- await self.__load_memory()
553
+ if "name" in cache and cache["name"] != "":
554
+ self._name = cache["name"]
555
+ else:
556
+ await self.__load_memory()
555
557
  # load the module status
556
558
  await self._request_module_status()
557
559
  # load the channel names
558
- await self._request_channel_name()
560
+ if "channels" in cache:
561
+ for num, chan in cache["channels"].items():
562
+ self._channels[int(num)]._name = chan["name"]
563
+ self._channels[int(num)]._is_loaded = True
564
+ else:
565
+ await self._request_channel_name()
559
566
  # load the module specific stuff
560
567
  self._load()
561
568
  # stop the loading
@@ -586,7 +593,11 @@ class Module:
586
593
  addr = "{high:02X}{low:02X}".format(
587
594
  high=message.high_address, low=message.low_address
588
595
  )
589
- mdata = self._data["Memory"]["1"]["Address"][addr]
596
+ if "Memory" not in self._data:
597
+ return
598
+ if "Address" not in self._data["Memory"]:
599
+ return
600
+ mdata = self._data["Memory"]["Address"][addr]
590
601
  if "ModuleName" in mdata and isinstance(self._name, dict):
591
602
  # if self._name is a dict we are still loading
592
603
  # if its a string it was already complete
@@ -702,9 +713,10 @@ class Module:
702
713
  self._name = None
703
714
  return
704
715
 
705
- for _memory_key, memory_part in self._data["Memory"].items():
706
- if "Address" in memory_part:
707
- for addr_int in memory_part["Address"].keys():
716
+ for memory_key, memory_part in self._data["Memory"].items():
717
+
718
+ if memory_key == "Address":
719
+ for addr_int in memory_part.keys():
708
720
  addr = struct.unpack(
709
721
  ">BB", struct.pack(">h", int("0x" + addr_int, 0))
710
722
  )
@@ -731,17 +743,6 @@ class Module:
731
743
  "ThermostatAddr" in self._data and self._data["ThermostatAddr"] != 0
732
744
  ):
733
745
  await self._update_channel(int(chan), {"thermostat": True})
734
- # add extra channel for program selection which is not in the channel list of the protocol.json file,
735
- # but is available in the messages list of the corresponding module.
736
- if keys_exists(self._data, "Messages", "B3"):
737
- self._channels[CHANNEL_SELECTED_PROGRAM] = SelectedProgram(
738
- self,
739
- CHANNEL_SELECTED_PROGRAM,
740
- "Selected Program",
741
- False,
742
- self._writer,
743
- self._address,
744
- )
745
746
 
746
747
 
747
748
  class VmbDali(Module):