velbus-aio 2023.2.0__py3-none-any.whl → 2023.5.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.

Potentially problematic release.


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

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: velbus-aio
3
- Version: 2023.2.0
3
+ Version: 2023.5.0
4
4
  Summary: Open-source home automation platform running on Python 3.
5
5
  Author-email: Maikel Punie <maikel.punie@gmail.com>
6
6
  License: MIT
@@ -1,22 +1,18 @@
1
- examples/discover.py,sha256=iCc2wO5-bZ-GO61rXvaHzjxbuFRwvAmUpevIchKMx2w,327
2
- examples/load_modules.py,sha256=1NYZfkElK8JKpIQEQJxuLJDykD26sOczzyqTeeLuiF0,951
3
- examples/read_bus.py,sha256=9BmB9oD_BdBQeMfBpZEH_BNpnjFwyIeWTydMmuKTwuk,974
4
- examples/read_cache.py,sha256=rP7qXg0j20TS1kE9r7lCYHCMznv7iCWICRSBLFlGIvA,343
5
1
  velbusaio/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- velbusaio/channels.py,sha256=3thGkot3frwiY-ZOuLPm2DmdYazhxbpQCoqYJNN5Fo0,20930
2
+ velbusaio/channels.py,sha256=FH1UO3IFqpQ6cxlQ2QHcEGk4uNXKdaeskPWr-k_ypNE,22129
7
3
  velbusaio/command_registry.py,sha256=tC3Mbz_h5YzKqEP5L_rvfgVczharNHS7T-Sollb0Rgk,4430
8
4
  velbusaio/const.py,sha256=swJuogDiNX_oKZVcIO5Lac3KYfiTNGieGMRPTHvLJV4,1548
9
5
  velbusaio/controller.py,sha256=srmhnY3iK8qrffx_uA3IeTaQq-8NYetxEFBfGDVdm0Y,9254
10
6
  velbusaio/discovery.py,sha256=Px6qoZl4QhF17aMz6JxstCORBpLzZGWEK9h4Vyvg57o,1649
11
7
  velbusaio/exceptions.py,sha256=js5Pj-vl6OTGWZUoRGBguutVXbvz_fVmslkCcmT2gps,486
12
- velbusaio/handler.py,sha256=9H2Mxo90zasp61kL7W7HoZ59We5_rchxQJjuHZOavFY,8344
8
+ velbusaio/handler.py,sha256=gI0Zma9SbcVEvAzYno4IJbqwtEYQk5Cp6zxVNtmox54,8342
13
9
  velbusaio/helpers.py,sha256=8PWyD13UA244ESk5YwPcRzvjK3OBAqmhwAwC6E9W4B4,2542
14
10
  velbusaio/message.py,sha256=ZFy0iup_DK_so_wZsr2F-3A4AJgQGxf5C3TXjK4BMW0,5047
15
- velbusaio/module.py,sha256=w1cRI6cmA-Wq6E1IJqI1wrqvHybzBml7Ps0Wx3wYq_I,34676
11
+ velbusaio/module.py,sha256=-Qg5_vIVpmd2vLjcGGXLfEKZKI4AE2s5FSq3bZXcREI,34889
16
12
  velbusaio/protocol.py,sha256=sut7jf3IJiJRx59w1EJs0AX4Aa15vrPNgIWJrtQkMjc,8220
17
13
  velbusaio/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- velbusaio/raw_message.py,sha256=scAZMJN8edrq2hquxeUF_BVs9v4uYLD5teA3K6YNuGI,4517
19
- velbusaio/util.py,sha256=U_MHfrNw_D3bVMP50VxL4wJFVjlsO5g2h4x124m6U50,1278
14
+ velbusaio/raw_message.py,sha256=5604X_0Itav6Ts89tXWvXs6sdx_KWRvPvSHjtFjXlMA,4613
15
+ velbusaio/util.py,sha256=eCsGQJ9nuzk_B2skBlv3MsNaMaHDXo1a1qSPjObzXH4,1540
20
16
  velbusaio/messages/__init__.py,sha256=0q0h3gIls7xJ-zzgLgV_C9G7IGkDa1Tp1vQ4CFY7gEs,5860
21
17
  velbusaio/messages/blind_status.py,sha256=3K5JRRn34_N1oQRKNBCkNwWIwhaURYL1ZNZhQZWFnSU,3417
22
18
  velbusaio/messages/bus_active.py,sha256=7aSGEASI4WxWZV9HI6P1b_p6wU1UvbJYmT90Hz_I8ls,748
@@ -39,7 +35,8 @@ velbusaio/messages/dali_device_settings_request.py,sha256=3IqaXOxqidJCJ1FxFMDofa
39
35
  velbusaio/messages/dali_dim_value_status.py,sha256=V2Fs8CZNihIi9ZxQs7Bxkt9qCInFXxMZnF6vKhIUCnQ,1044
40
36
  velbusaio/messages/dimmer_channel_status.py,sha256=nJ_83uVe0FIiwWmGt7XNXcRYu3ikNUwxOOg5nHzaOPw,2470
41
37
  velbusaio/messages/dimmer_status.py,sha256=OWaChsyloAvRoywn-LlNz8LeuZKj3k3eNzL5mH49pM4,2927
42
- velbusaio/messages/edge_set_custom_color.py,sha256=6hj1hj5w0oEnsOSQ_ih6yGGd0MfasLFrojbiN_80i2Q,1273
38
+ velbusaio/messages/edge_set_color.py,sha256=enwPshhNrleAQQwc3RobPt5foZ1ynE_74SlBEuzd86w,3305
39
+ velbusaio/messages/edge_set_custom_color.py,sha256=fw4hQTrTxNBb63XLTY9iLFtPYrNh0mAAE28DCxG9h1A,1337
43
40
  velbusaio/messages/fast_blinking_led.py,sha256=Q5scu34RQJZ43EDZCR1kJy63gULSWHN5bpKpqo_XOOc,908
44
41
  velbusaio/messages/forced_off.py,sha256=QQiwMbVUW6wegyTLrf1daJiS8KggPXZvepGsBU9_FUo,590
45
42
  velbusaio/messages/forced_on.py,sha256=tS7dUayO_0Grco5TfiOMWBUOc0CY44w_7FcpU-ZViJU,589
@@ -64,14 +61,14 @@ velbusaio/messages/realtime_clock_status_request.py,sha256=KEvcmWlgN4XbpHSA90fg3
64
61
  velbusaio/messages/receive_buffer_full.py,sha256=dgyzmZ8VxhQk8r4vUs2uWuojut2Akj4IMazkqfDa1e4,857
65
62
  velbusaio/messages/receive_ready.py,sha256=f1LdUVcUTG7rj71wCVHgF03zbkIx4CpJKG7zgXIERf4,686
66
63
  velbusaio/messages/relay_status.py,sha256=BBJHM54gzbOTAoQ_N8ls3IiJoOIklKFCvBU4odntXvM,2836
67
- velbusaio/messages/restore_dimmer.py,sha256=Uvf-y7znulDr2dXe6moB-jsYLzDzyXMxbnUakUDSJQQ,1656
64
+ velbusaio/messages/restore_dimmer.py,sha256=W2SGCAMA91cDWd4359RInhB3z4tvnfJ6vPLW2Ycu3vU,1718
68
65
  velbusaio/messages/select_program.py,sha256=RHvOvWXC7w8wxMhco0NUDPIMK6r6Q2LCd87Kdnl7hxI,834
69
66
  velbusaio/messages/sensor_settings_request.py,sha256=njSYjNTxhNyRKJLP7wexaWHnYiSWbrSlOm_F7myuBdw,818
70
67
  velbusaio/messages/sensor_temp_request.py,sha256=R-VNtqqiDbgZjPNfj5nE0_bTuGLD74Zy-FUsrCcyXFI,598
71
68
  velbusaio/messages/sensor_temperature.py,sha256=Erh7pIrbxpmurg3x9_di6A6Os_2Sgpid7T6LgHuWQyA,1557
72
69
  velbusaio/messages/set_date.py,sha256=cHUmzLxji3WZisRQErX3m3EdnqwkdyQx3_1Ok6x6aYs,1426
73
70
  velbusaio/messages/set_daylight_saving.py,sha256=Ihnshq7C1u7-sRN5fKKt3ZlHmOz9-Kj8lbddwQ9Ya9I,1084
74
- velbusaio/messages/set_dimmer.py,sha256=AXnzyrgSlRtfJ6jNYuWzPnZaFDV17DNxusewvj5UtYw,1864
71
+ velbusaio/messages/set_dimmer.py,sha256=BDIOqLO9KuPWfzn0Ox56VPquRxlwyIdkmCFphrbBZho,1926
75
72
  velbusaio/messages/set_led.py,sha256=hNmbmS2hXqTBVfXMWYhyf10-BOvd5ZwimMd74Cyj5PQ,899
76
73
  velbusaio/messages/set_realtime_clock.py,sha256=H89tNgxDH5uotjwGbCM05qDMe0ZWhs7dRyyS3n6OLzA,1275
77
74
  velbusaio/messages/set_temperature.py,sha256=PMs_uXWMhggIX0s2ikediwTJ4WSpvrXzahCJ0Ak_hks,958
@@ -99,8 +96,8 @@ velbusaio/messages/write_data_to_memory.py,sha256=2bC-vuv_RK3hGxvKeba1zR405ffj-C
99
96
  velbusaio/messages/write_memory_block.py,sha256=5pP4hCRV7tc5xYxHO_51t-uCYgNtVHiaPic_ZGG2Y9s,1031
100
97
  velbusaio/messages/write_module_address_and_serial_number.py,sha256=gU-yAHxICP6LPQX7BRj-WUfiVpTk0sV1CMlXeElAwl4,1596
101
98
  velbusaio/moduleprotocol/protocol.json,sha256=zChwegR8Ic_Msw5iVMV_W3kVmSyK5DwYof46wD7l9H8,883766
102
- velbus_aio-2023.2.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
103
- velbus_aio-2023.2.0.dist-info/METADATA,sha256=Ql8T8j4ICxzGS3dNO2wjlI_cBfP-qLXeFl6YfChvG9A,3033
104
- velbus_aio-2023.2.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
105
- velbus_aio-2023.2.0.dist-info/top_level.txt,sha256=_l716Lmicfc7vihDNaGKb49LJvqGSlJIUkSRHB51wpo,24
106
- velbus_aio-2023.2.0.dist-info/RECORD,,
99
+ velbus_aio-2023.5.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
100
+ velbus_aio-2023.5.0.dist-info/METADATA,sha256=KnnfurH3T9H8mUbGwaOQY7peciOj0t3zObPZ4L9PwoY,3033
101
+ velbus_aio-2023.5.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
102
+ velbus_aio-2023.5.0.dist-info/top_level.txt,sha256=W0-lSOwD23mm8FqaIe9vY20fKicBMIdUVjF-zmfxRnY,15
103
+ velbus_aio-2023.5.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: bdist_wheel (0.40.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,3 +1,2 @@
1
1
  dist
2
- examples
3
2
  velbusaio
velbusaio/channels.py CHANGED
@@ -18,6 +18,7 @@ from velbusaio.const import (
18
18
  VOLUME_LITERS_HOUR,
19
19
  )
20
20
  from velbusaio.message import Message
21
+ from velbusaio.messages.edge_set_color import SetEdgeColorMessage, CustomColorPriority
21
22
  from velbusaio.messages.module_status import PROGRAM_SELECTION
22
23
 
23
24
  if TYPE_CHECKING:
@@ -275,6 +276,7 @@ class Button(Channel):
275
276
  _enabled = True
276
277
  _closed = False
277
278
  _led_state = None
279
+ _long = False
278
280
 
279
281
  def get_categories(self) -> list[str]:
280
282
  if self._enabled:
@@ -702,8 +704,42 @@ class EdgeLit(Channel):
702
704
  An EdgeLit channel
703
705
  """
704
706
 
705
- # def get_categories(self):
706
- # return ["light"]
707
+ async def reset_color(self, left=True, top=True, right=True, bottom=True):
708
+ msg = SetEdgeColorMessage(self._address)
709
+ msg.apply_background_color = True
710
+ msg.color_idx = 0
711
+ msg.apply_to_left_edge = left
712
+ msg.apply_to_top_edge = top
713
+ msg.apply_to_right_edge = right
714
+ msg.apply_to_bottom_edge = bottom
715
+ msg.apply_to_all_pages = True
716
+ await self._writer(msg)
717
+
718
+ async def set_color(
719
+ self,
720
+ color_idx: int,
721
+ left=True,
722
+ top=True,
723
+ right=True,
724
+ bottom=True,
725
+ blinking=False,
726
+ priority=CustomColorPriority.LOW_PRIORITY,
727
+ ) -> None:
728
+ """
729
+ Send the turn off message
730
+ """
731
+
732
+ msg = SetEdgeColorMessage(self._address)
733
+ msg.apply_background_color = True
734
+ msg.background_blinking = blinking
735
+ msg.color_idx = color_idx
736
+ msg.apply_to_left_edge = left
737
+ msg.apply_to_top_edge = top
738
+ msg.apply_to_right_edge = right
739
+ msg.apply_to_bottom_edge = bottom
740
+ msg.apply_to_all_pages = True
741
+ msg.custom_color_priority = priority
742
+ await self._writer(msg)
707
743
 
708
744
 
709
745
  class Memo(Channel):
velbusaio/handler.py CHANGED
@@ -101,7 +101,7 @@ class PacketHandler:
101
101
  msg.populate(priority, address, rtr, data)
102
102
  self._log.debug(f"Received {msg}")
103
103
  # send the message to the modules
104
- await (self._velbus.get_module(msg.address)).on_message(msg)
104
+ await self._velbus.get_module(msg.address).on_message(msg)
105
105
  else:
106
106
  self._log.warning(
107
107
  "NOT FOUND IN command_registry: addr={} cmd={} packet={}".format(
@@ -0,0 +1,113 @@
1
+ from __future__ import annotations
2
+
3
+ from enum import IntEnum
4
+ from velbusaio.command_registry import register
5
+ from velbusaio.message import Message
6
+
7
+ COMMAND_CODE = 0xD4
8
+
9
+
10
+ class CustomColorPriority(IntEnum):
11
+ LOW_PRIORITY = 1
12
+ MID_PRIORITY = 2
13
+ HIGH_PRIORITY = 3
14
+
15
+
16
+ @register(COMMAND_CODE, ["VMBEL1", "VMBEL2", "VMBEL4", "VMBELO"])
17
+ class SetEdgeColorMessage(Message):
18
+ """
19
+ send by:
20
+ received by: VMBEL1, VMBEL2, VMBEL4, VMBELO
21
+ """
22
+
23
+ apply_background_color = False
24
+ apply_continuous_feedback_color = False
25
+ apply_slow_blinking_feedback_color = False
26
+ apply_fast_blinking_feedback_color = False
27
+ custom_color_palette = False
28
+
29
+ apply_to_left_edge = False
30
+ apply_to_top_edge = False
31
+ apply_to_right_edge = False
32
+ apply_to_bottom_edge = False
33
+
34
+ apply_to_page: int | None = None
35
+ apply_to_all_pages = False
36
+
37
+ background_blinking = False
38
+ custom_color_priority: CustomColorPriority | None = None
39
+
40
+ color_idx: int = 0
41
+
42
+ def populate(self, priority, address, rtr, data):
43
+ """
44
+ :return: None
45
+ """
46
+ self.needs_no_rtr(rtr)
47
+ self.set_attributes(priority, address, rtr)
48
+
49
+ self.apply_background_color = bool(data[0] & 0x01)
50
+ self.apply_continuous_feedback_color = bool(data[0] & 0x02)
51
+ self.apply_slow_blinking_feedback_color = bool(data[0] & 0x04)
52
+ self.apply_fast_blinking_feedback_color = bool(data[0] & 0x08)
53
+ self.custom_color_palette = bool(data[0] & 0x80)
54
+
55
+ self.apply_to_left_edge = bool(data[1] & 0x01)
56
+ self.apply_to_top_edge = bool(data[1] & 0x02)
57
+ self.apply_to_right_edge = bool(data[1] & 0x04)
58
+ self.apply_to_bottom_edge = bool(data[1] & 0x08)
59
+
60
+ page = (data[1] & 0b0111_0000) >> 4
61
+ if page > 0:
62
+ self.apply_to_page = page
63
+ self.apply_to_all_pages = bool(data[1] & 0x80)
64
+
65
+ self.background_blinking = bool(data[2] & 0x80)
66
+
67
+ custom_color_priority_value = data[2] & 0b0110_0000 >> 5
68
+ if custom_color_priority_value:
69
+ self.custom_color_priority = CustomColorPriority(
70
+ custom_color_priority_value
71
+ )
72
+
73
+ self.color_idx = data[2] & 0b0001_1111
74
+
75
+ def data_to_binary(self):
76
+ """
77
+ :return: bytes
78
+ """
79
+
80
+ byte_2 = (
81
+ self.apply_background_color * 0x01
82
+ + self.apply_continuous_feedback_color * 0x02
83
+ + self.apply_slow_blinking_feedback_color * 0x04
84
+ + self.apply_fast_blinking_feedback_color * 0x08
85
+ + self.custom_color_palette * 0x80
86
+ )
87
+
88
+ byte_3 = (
89
+ self.apply_to_left_edge * 0x01
90
+ + self.apply_to_top_edge * 0x02
91
+ + self.apply_to_right_edge * 0x04
92
+ + self.apply_to_bottom_edge * 0x08
93
+ + (((self.apply_to_page or 0) & 0xFFF) << 4)
94
+ + self.apply_to_all_pages * 0x80
95
+ )
96
+
97
+ byte_4 = (
98
+ (self.color_idx & 0xFFFF)
99
+ + (
100
+ (int(self.custom_color_priority) if self.custom_color_priority else 0)
101
+ << 5
102
+ )
103
+ + self.background_blinking * 0x80
104
+ )
105
+
106
+ return bytes(
107
+ [
108
+ COMMAND_CODE,
109
+ byte_2,
110
+ byte_3,
111
+ byte_4,
112
+ ]
113
+ )
@@ -9,11 +9,11 @@ from velbusaio.message import Message
9
9
  COMMAND_CODE = 0xD4
10
10
 
11
11
 
12
- @register(COMMAND_CODE)
12
+ @register(COMMAND_CODE, ["VMBEL1", "VMBEL2", "VMBEL4", "VMBELO"])
13
13
  class EdgeSetCustomColor(Message):
14
14
  """
15
15
  send by:
16
- received by: VMB4RYLD
16
+ received by: VMBEL1, VMBEL2, VMBEL4, VMBELO
17
17
  """
18
18
 
19
19
  def __init__(self, address=None):
@@ -59,5 +59,6 @@ class RestoreDimmerMessage2(RestoreDimmerMessage):
59
59
  return [byte]
60
60
 
61
61
  def channels_to_byte(self, channels: list[int]) -> int:
62
- assert len(channels) == 1
62
+ if len(channels) != 1:
63
+ raise ValueError("We should have exact one channel")
63
64
  return channels[0]
@@ -67,5 +67,6 @@ class SetDimmerMessage2(SetDimmerMessage):
67
67
  return [byte]
68
68
 
69
69
  def channels_to_byte(self, channels) -> int:
70
- assert len(channels) == 1
70
+ if len(channels) != 1:
71
+ raise ValueError("We should have exact one channel")
71
72
  return channels[0]
velbusaio/module.py CHANGED
@@ -176,7 +176,7 @@ class Module:
176
176
  # The solution would be that this functions knows were the temperature channels are located
177
177
  # and/or what the max number of subaddresses are for each module.
178
178
  if self._sub_address == {}:
179
- assert "No subaddresses defined"
179
+ raise Exception("No subaddresses defined")
180
180
  for sub in range(1, 4):
181
181
  if sub not in self._sub_address:
182
182
  for i in range(((sub * 8) + 1), (((sub + 1) * 8) + 1)):
@@ -372,8 +372,12 @@ class Module:
372
372
  channel = self._translate_channel_name(channel_id + _channel_offset)
373
373
  if channel_id in message.closed:
374
374
  await self._update_channel(channel, {"closed": True})
375
+ if channel_id in message.closed_long:
376
+ await self._update_channel(channel, {"long": True})
375
377
  if channel_id in message.opened:
376
- await self._update_channel(channel, {"closed": False})
378
+ await self._update_channel(
379
+ channel, {"closed": False, "long": False}
380
+ )
377
381
  elif isinstance(message, (ModuleStatusMessage)):
378
382
  for channel_id in range(1, 9):
379
383
  channel = self._translate_channel_name(channel_id + _channel_offset)
velbusaio/raw_message.py CHANGED
@@ -78,10 +78,10 @@ class ParseError(Exception):
78
78
 
79
79
 
80
80
  def _parse(rawmessage: bytearray) -> Tuple[Optional[RawMessage], bytearray]:
81
- assert (
82
- MINIMUM_MESSAGE_SIZE <= len(rawmessage) <= MAXIMUM_MESSAGE_SIZE
83
- ), "Received a raw message with an illegal length"
84
- assert rawmessage[0] == START_BYTE
81
+ if len(rawmessage) < MINIMUM_MESSAGE_SIZE or len(rawmessage) > MAXIMUM_MESSAGE_SIZE:
82
+ raise ValueError("Received a raw message with an illegal lemgth")
83
+ if rawmessage[0] != START_BYTE:
84
+ raise ValueError("Received a raw message with the wrong startbyte")
85
85
 
86
86
  priority = rawmessage[1]
87
87
  if priority not in PRIORITIES:
velbusaio/util.py CHANGED
@@ -6,8 +6,10 @@ from velbusaio.const import MAXIMUM_MESSAGE_SIZE, MINIMUM_MESSAGE_SIZE
6
6
  # Copyright (c) 2017 Thomas Delaet
7
7
  # Copied from python-velbus (https://github.com/thomasdelaet/python-velbus)
8
8
  def checksum(data: Union[bytes, bytearray]) -> int:
9
- assert len(data) >= MINIMUM_MESSAGE_SIZE - 2
10
- assert len(data) <= MAXIMUM_MESSAGE_SIZE - 2
9
+ if len(data) < MINIMUM_MESSAGE_SIZE - 2:
10
+ raise ValueError("The message is shorter then expected")
11
+ if len(data) > MAXIMUM_MESSAGE_SIZE - 2:
12
+ raise ValueError("The message is longer then expected")
11
13
  __checksum = 0
12
14
  for data_byte in data:
13
15
  __checksum += data_byte
@@ -35,12 +37,13 @@ class BitSet:
35
37
  self._value = value
36
38
 
37
39
  def __getitem__(self, idx: int) -> bool:
38
- assert 0 <= idx < 8
40
+ if idx > 8 or idx <= 0:
41
+ raise ValueError("The bitSet id is not within expected range 0 < id < 8")
39
42
  return bool((1 << idx) & self._value)
40
43
 
41
44
  def __setitem__(self, idx: int, value: bool) -> None:
42
- assert 0 <= idx < 8
43
- assert isinstance(value, bool)
45
+ if idx > 8 or idx <= 0:
46
+ raise ValueError("The bitSet id is not within expected range 0 < id < 8")
44
47
  mask = (0xFF ^ (1 << idx)) & self._value
45
48
  self._value = mask & (value << idx)
46
49
 
examples/discover.py DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- import asyncio
4
-
5
- from velbusaio.discovery import VelbusDiscoveryProtocol
6
-
7
- loop = asyncio.get_event_loop()
8
- coro = loop.create_datagram_endpoint(
9
- lambda: VelbusDiscoveryProtocol(("192.168.1.255", 32767)),
10
- local_addr=("0.0.0.0", 1900),
11
- )
12
- loop.run_until_complete(coro)
13
- loop.run_forever()
14
- loop.close()
examples/load_modules.py DELETED
@@ -1,33 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- import argparse
4
- import asyncio
5
- import logging
6
- import sys
7
-
8
- from velbusaio.controller import Velbus
9
-
10
- parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
11
- parser.add_argument("--connect", help="Connection string", default="192.168.1.254:8445")
12
- args = parser.parse_args()
13
-
14
-
15
- async def main(connect_str: str):
16
- # SET THE connection params below
17
- # example via signum:
18
- # velbus = Velbus("tls://192.168.1.9:27015")
19
- # example via plain IP
20
- # velbus = Velbus("192.168.1.9:27015")
21
- # example via serial device
22
- # velbus = Velbus("/dev/ttyAMA0")
23
- velbus = Velbus(connect_str)
24
- await velbus.connect()
25
- for mod in (velbus.get_modules()).values():
26
- print(mod)
27
- print("")
28
- await velbus.stop()
29
-
30
-
31
- logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
32
- logging.getLogger("asyncio").setLevel(logging.DEBUG)
33
- asyncio.run(main(args.connect), debug=False)
examples/read_bus.py DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- import argparse
4
- import asyncio
5
- import logging
6
- import sys
7
-
8
- from velbusaio.controller import Velbus
9
-
10
- parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
11
- parser.add_argument(
12
- "--connect", help="Connection string", default="tls://192.168.1.9:27015"
13
- )
14
- args = parser.parse_args()
15
-
16
-
17
- async def main(connect_str: str):
18
- # SET THE connection params below
19
- # example via signum:
20
- # velbus = Velbus("tls://192.168.1.9:27015")
21
- # example via plain IP
22
- # velbus = Velbus("192.168.1.9:27015")
23
- # example via serial device
24
- # velbus = Velbus("/dev/ttyAMA0")
25
- velbus = Velbus(connect_str)
26
- await velbus.connect()
27
- for mod in (velbus.get_modules()).values():
28
- print(mod)
29
- print("")
30
- await asyncio.sleep(6000000000)
31
-
32
-
33
- logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
34
- logging.getLogger("asyncio").setLevel(logging.DEBUG)
35
- asyncio.run(main(args.connect), debug=False)
examples/read_cache.py DELETED
@@ -1,12 +0,0 @@
1
- import pickle
2
- from os import listdir
3
- from os.path import isfile, join
4
-
5
- from velbusaio.const import CACHEDIR
6
- from velbusaio.helpers import get_cache_dir
7
-
8
- for fil in [f for f in listdir(get_cache_dir()) if isfile(join(get_cache_dir(), f))]:
9
- print("")
10
- print(fil)
11
- fl = open(f"{get_cache_dir()}/{fil}", "rb")
12
- print(pickle.load(fl))