boneIO 0.9.4.dev2__py3-none-any.whl → 0.9.4.dev4__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.
@@ -0,0 +1,106 @@
1
+ - id: IN_01
2
+ boneio_input: IN_01
3
+ actions:
4
+ pressed:
5
+ - action: output
6
+ pin: OUT_01
7
+ - id: IN_02
8
+ boneio_input: IN_02
9
+ actions:
10
+ pressed:
11
+ - action: output
12
+ pin: OUT_02
13
+ # - id: IN_03
14
+ # boneio_input: IN_03
15
+ # - id: IN_04
16
+ # boneio_input: IN_04
17
+ # - id: IN_05
18
+ # boneio_input: IN_05
19
+ # - id: IN_06
20
+ # boneio_input: IN_06
21
+ # - id: IN_07
22
+ # boneio_input: IN_07
23
+ # - id: IN_08
24
+ # boneio_input: IN_08
25
+ # - id: IN_09
26
+ # boneio_input: IN_09
27
+ # - id: IN_10
28
+ # boneio_input: IN_10
29
+ # - id: IN_11
30
+ # boneio_input: IN_11
31
+ # - id: IN_12
32
+ # boneio_input: IN_12
33
+ # - id: IN_13
34
+ # boneio_input: IN_13
35
+ # - id: IN_14
36
+ # boneio_input: IN_14
37
+ # - id: IN_15
38
+ # boneio_input: IN_15
39
+ # - id: IN_16
40
+ # boneio_input: IN_16
41
+ # - id: IN_17
42
+ # boneio_input: IN_17
43
+ # - id: IN_18
44
+ # boneio_input: IN_18
45
+ # - id: IN_19
46
+ # boneio_input: IN_19
47
+ # - id: IN_20
48
+ # boneio_input: IN_20
49
+ # - id: IN_21
50
+ # boneio_input: IN_21
51
+ # - id: IN_22
52
+ # boneio_input: IN_22
53
+ # - id: IN_23
54
+ # boneio_input: IN_23
55
+ # - id: IN_24
56
+ # boneio_input: IN_24
57
+ # - id: IN_25
58
+ # boneio_input: IN_25
59
+ # - id: IN_26
60
+ # boneio_input: IN_26
61
+ # - id: IN_27
62
+ # boneio_input: IN_27
63
+ # - id: IN_28
64
+ # boneio_input: IN_28
65
+ # - id: IN_29
66
+ # boneio_input: IN_29
67
+ # - id: IN_30
68
+ # boneio_input: IN_30
69
+ # - id: IN_31
70
+ # boneio_input: IN_31
71
+ # - id: IN_32
72
+ # boneio_input: IN_32
73
+ # - id: IN_33
74
+ # boneio_input: IN_33
75
+ # - id: IN_34
76
+ # boneio_input: IN_34
77
+ # - id: IN_35
78
+ # boneio_input: IN_35
79
+ # - id: IN_36
80
+ # boneio_input: IN_36
81
+ # - id: IN_37
82
+ # boneio_input: IN_37
83
+ # - id: IN_38
84
+ # boneio_input: IN_38
85
+ # - id: IN_39
86
+ # boneio_input: IN_39
87
+ # - id: IN_40
88
+ # boneio_input: IN_40
89
+ # - id: IN_41
90
+ # boneio_input: IN_41
91
+ # - id: IN_42
92
+ # boneio_input: IN_42
93
+ # - id: IN_43
94
+ # boneio_input: IN_43
95
+ # - id: IN_44
96
+ # boneio_input: IN_44
97
+ # - id: IN_45
98
+ # boneio_input: IN_45
99
+ # - id: IN_46
100
+ # boneio_input: IN_46
101
+ # - id: IN_47
102
+ # boneio_input: IN_47
103
+ # - id: IN_48
104
+ # boneio_input: IN_48
105
+ # - id: IN_49
106
+ # boneio_input: IN_49
@@ -15,7 +15,7 @@ lm75:
15
15
  event: !include event.yaml
16
16
  binary_sensor: !include binary_sensor.yaml
17
17
 
18
- output: !include output32x5A.yaml
18
+ output: !include output32x10A_new.yaml
19
19
 
20
20
  boneio:
21
21
  name: "boneIO Black 32x10A"
boneio/helper/queue.py CHANGED
@@ -4,29 +4,55 @@ If MQTT is down then regular queue can append multiple ON/OFF for same topic.
4
4
  After re-connection it would send all messages. It's not necessary, last payload of same topic is enough.
5
5
  """
6
6
  import asyncio
7
+ from typing import Any, Dict, Tuple
7
8
 
8
9
 
9
10
  class UniqueQueue(asyncio.Queue):
10
- """Unique implementation of asyncio.Queue."""
11
+ """Unique implementation of asyncio.Queue that handles MQTT connection state."""
11
12
 
12
- def _init(self, maxsize):
13
- """Create unique dict of tuple[0]."""
13
+ def __init__(self, maxsize: int = 0):
14
+ """Initialize the queue."""
15
+ super().__init__(maxsize=maxsize)
16
+ self._unique_items: Dict[str, Tuple[Any, ...]] = {}
17
+ self._is_connected = False
18
+
19
+ def set_connected(self, state: bool) -> None:
20
+ """Set the connection state."""
21
+ self._is_connected = state
22
+
23
+ def _init(self, maxsize: int) -> None:
24
+ """Initialize the internal queue storage."""
14
25
  super()._init(maxsize=maxsize)
15
- self._unique_set = {}
26
+ self._unique_items = {}
16
27
 
17
- def _put(self, item):
18
- """If item does not exists add it.
19
- If exists remove old one and put new one in the beginning of the queue."""
20
- if item[0] not in self._unique_set:
28
+ def _put(self, item: Tuple[str, Any, bool]) -> None:
29
+ """Put an item into the queue.
30
+
31
+ If MQTT is not connected:
32
+ - If topic exists, replace the old message
33
+ - If topic doesn't exist, add new message
34
+ If MQTT is connected:
35
+ - Add all messages to queue
36
+
37
+ Args:
38
+ item: Tuple of (topic, payload, retain)
39
+ """
40
+ topic = item[0]
41
+
42
+ if not self._is_connected:
43
+ # When disconnected, replace existing messages for same topic
44
+ if topic in self._unique_items:
45
+ self._queue.remove(self._unique_items[topic])
21
46
  super()._put(item)
22
- self._unique_set[item[0]] = item
47
+ self._unique_items[topic] = item
23
48
  else:
24
- self._queue.remove(self._unique_set[item[0]])
49
+ # When connected, queue all messages
25
50
  super()._put(item)
26
- self._unique_set[item[0]] = item
51
+ self._unique_items[topic] = item
27
52
 
28
- def _get(self):
29
- """Get item and remove it."""
53
+ def _get(self) -> Tuple[str, Any, bool]:
54
+ """Get an item from the queue and remove it from unique items tracking."""
30
55
  item = super()._get()
31
- del self._unique_set[item[0]]
56
+ if item[0] in self._unique_items:
57
+ del self._unique_items[item[0]]
32
58
  return item
boneio/manager.py CHANGED
@@ -778,13 +778,17 @@ class Manager:
778
778
  """Callback for receiving action from Mqtt."""
779
779
  _LOGGER.debug("Processing topic %s with message %s.", topic, message)
780
780
  if topic.startswith(
781
- f"{self._config_helper.topic_prefix}/status"
781
+ f"{self._config_helper.ha_discovery_prefix}/status"
782
782
  ):
783
783
  if message == ONLINE:
784
784
  self.resend_autodiscovery()
785
785
  self._event_bus.signal_ha_online()
786
786
  return
787
- assert topic.startswith(self._config_helper.cmd_topic_prefix)
787
+ try:
788
+ assert topic.startswith(self._config_helper.cmd_topic_prefix)
789
+ except AssertionError as err:
790
+ _LOGGER.error("Wrong topic %s. Error %s", topic, err)
791
+ return
788
792
  topic_parts_raw = topic[
789
793
  len(self._config_helper.cmd_topic_prefix) :
790
794
  ].split("/")
boneio/mqtt_client.py CHANGED
@@ -19,10 +19,10 @@ from paho.mqtt.properties import Properties
19
19
  from paho.mqtt.subscribeoptions import SubscribeOptions
20
20
 
21
21
  from boneio.const import OFFLINE, PAHO, STATE
22
- from boneio.helper import UniqueQueue
23
22
  from boneio.helper.config import ConfigHelper
24
23
  from boneio.helper.events import GracefulExit
25
24
  from boneio.helper.message_bus import MessageBus
25
+ from boneio.helper.queue import UniqueQueue
26
26
  from boneio.manager import Manager
27
27
 
28
28
  _LOGGER = logging.getLogger(__name__)
@@ -174,7 +174,7 @@ class MQTTClient(MessageBus):
174
174
  await self._subscribe_manager(self._manager)
175
175
  except MqttError as err:
176
176
  self.reconnect_interval = min(
177
- self.reconnect_interval * 2, 600
177
+ self.reconnect_interval * 2, 60
178
178
  )
179
179
  _LOGGER.error(
180
180
  "MQTT error: %s. Reconnecting in %s seconds",
@@ -182,6 +182,7 @@ class MQTTClient(MessageBus):
182
182
  self.reconnect_interval,
183
183
  )
184
184
  self._connection_established = False
185
+ self.publish_queue.set_connected(False)
185
186
  await asyncio.sleep(self.reconnect_interval)
186
187
  self.create_client() # reset connect/reconnect futures
187
188
  except (asyncio.CancelledError, GracefulExit):
@@ -194,21 +195,19 @@ class MQTTClient(MessageBus):
194
195
 
195
196
  async def _subscribe_manager(self, manager: Manager) -> None:
196
197
  """Connect and subscribe to manager topics + host stats."""
197
- # Create a new future for this run
198
- self._cancel_future = asyncio.Future()
199
-
200
- async def wait_for_cancel():
201
- await self._cancel_future
202
- # When future completes, raise CancelledError to stop other tasks
203
- raise asyncio.CancelledError("Stop requested")
204
-
205
198
  async with AsyncExitStack() as stack:
206
- tasks: Set[asyncio.Task] = set()
207
-
208
- # Connect to the MQTT broker.
209
199
  await stack.enter_async_context(self.asyncio_client)
210
- # Reset the reconnect interval after successful connection.
211
- self.reconnect_interval = 1
200
+ self._connection_established = True
201
+ self.publish_queue.set_connected(True)
202
+ # Create a new future for this run
203
+ self._cancel_future = asyncio.Future()
204
+
205
+ async def wait_for_cancel():
206
+ await self._cancel_future
207
+ # When future completes, raise CancelledError to stop other tasks
208
+ raise asyncio.CancelledError("Stop requested")
209
+
210
+ tasks: Set[asyncio.Task] = set()
212
211
 
213
212
  publish_task = asyncio.create_task(self._handle_publish())
214
213
  tasks.add(publish_task)
boneio/version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  # flake8: noqa
2
- __version__ = "0.9.4dev2"
2
+ __version__ = "0.9.4dev4"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: boneio
3
- Version: 0.9.4dev2
3
+ Version: 0.9.4dev4
4
4
  Summary: Python App for BoneIO
5
5
  License: GNU General Public License v3.0
6
6
  Author-email: Paweł Szafer <pszafer@gmail.com>
@@ -10,9 +10,10 @@ boneio/const.py,sha256=ZYy0z_2cPDWH0zkIw4bO-UBYXgXVNLoBAefgDOBV7Mw,5134
10
10
  boneio/cover.py,sha256=Cz9s92YciEvrE7iAB3aoP38ABN90HjG1U5v5rM9oeA8,8620
11
11
  boneio/example_config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  boneio/example_config/adc.yaml,sha256=GKNpl2t7ebsH57UhJlJioXNuBflsL6eO4JMnyYwZrFs,168
13
+ boneio/example_config/all_binary_sensor.yaml,sha256=f8jsCMVUZYD0PE6bDfYm6k7BTNXsmzAobDd9X98L-A4,1987
13
14
  boneio/example_config/binary_sensor.yaml,sha256=4oErCX-5t6e9e0KVo5GkkFplKkgKs0st-wTmyiCZNzM,286
14
15
  boneio/example_config/binary_sensor_v_0_7.yaml,sha256=uaIDVV7t4drhlBDu_IK-ZK1DiMqqCP9tCi_HfS7KP5I,185
15
- boneio/example_config/config.yaml,sha256=C-NtH372Q9Ifv6boLSKimALpPQQt3zeEcZqQzEuo3wI,405
16
+ boneio/example_config/config.yaml,sha256=miGRJU9gzTYry3uEibfCwXMomi994ngBoQ-ApgoyMjk,410
16
17
  boneio/example_config/cover.yaml,sha256=rs7lv3vIEgAb3q96RKsJL7VMRsEvSNHG848dzZzSKsI,150
17
18
  boneio/example_config/event.yaml,sha256=9TMKXGLTAz4umSJCiMs53ReFmhY84LtmEPnanIIw-uY,2692
18
19
  boneio/example_config/event_all.yaml,sha256=9TMKXGLTAz4umSJCiMs53ReFmhY84LtmEPnanIIw-uY,2692
@@ -46,7 +47,7 @@ boneio/helper/onewire/__init__.py,sha256=4djH-uxiq5XhAiFTOxyqjvWVoJe0c8U8iN0BfmH
46
47
  boneio/helper/onewire/ds2482.py,sha256=c2t_hdAMtFsHw4Vw41QzO_hEDDNMeb3J71mEwEMUBhM,5169
47
48
  boneio/helper/onewire/onewire.py,sha256=tHofTu1l0qG7hH2XoSf-lj8gW7wVKe27j57qQWpVMPg,2497
48
49
  boneio/helper/pcf8575.py,sha256=qeNYLqV5foDEQCyAz1WRQRi1CYYxtbPIha06Z5TyZVQ,311
49
- boneio/helper/queue.py,sha256=7fE7d344-BEW8sljN40wmqsbBr4kPLvz4ShBjkT04p8,1066
50
+ boneio/helper/queue.py,sha256=p0MGzgFnsLgpc98FNHCoQdIS75IJnO9qkCMFsTA2Hvk,2067
50
51
  boneio/helper/schema_converter.py,sha256=1kT0i5ofqYT0TSbdRftBgsiww13u6bpy4q3_TZXx4iI,7919
51
52
  boneio/helper/sensor/ina_219_smbus.py,sha256=eXp2epjUgsqaXamTSWSn3LMow5X_YxAxdREaWD7N3mk,6170
52
53
  boneio/helper/state_manager.py,sha256=T-1kPZlMqo05jCRE7widQeO5zXV08nsvmZh8k9HJJEk,2522
@@ -57,7 +58,7 @@ boneio/helper/yaml_util.py,sha256=SW7u6i4Re_u4bm-aW-_Wk9piQz949kgjiwk8Y3kTObY,18
57
58
  boneio/input/__init__.py,sha256=8Hcps-wCCl6bCAMoEmDJecR-Q9giFL29AvG1ZGe0dZw,200
58
59
  boneio/input/gpio.py,sha256=vdQuvWlwV41mbLgLRi-z1vpmRj61HDsmbJrYUoCOHkM,2675
59
60
  boneio/input/gpio_new.py,sha256=Br2Lw5bci1_qb_UO63tJr4uBSjCkBvjGdzla4s1ctS8,3050
60
- boneio/manager.py,sha256=XC-gWMaWJPnDkAcZSWB_sU8LYOHc6YWDcrGUoZ73Viw,32887
61
+ boneio/manager.py,sha256=Ezqv_SkIGImpaCUMpTRmUzBr-i_hvGKc4qqjfXXSOtM,33034
61
62
  boneio/modbus/__init__.py,sha256=yeHIxZ0_u7eCL7CqScvob5Utcru6Iza0LEtTagEtNtw,116
62
63
  boneio/modbus/client.py,sha256=v_w6HOFH4e-CWcSjpyBojLhglIqJ6kPVXOLEDAEmsI0,8137
63
64
  boneio/modbus/cwt.json,sha256=PCn9t5wQkNCD8AqwXSoJ3cEm50bKAX4FmPw6fWCvLrg,908
@@ -80,7 +81,7 @@ boneio/modbus/utils.py,sha256=RQFLNGHkT3mFsNmYKR34uaZr33ZnFa_j0BN7qnI5-uQ,1765
80
81
  boneio/models/__init__.py,sha256=RiXQsIBXKaS0LkZ085EppB99MIp-eKZZbQ8XpS2Urnk,1181
81
82
  boneio/models/files.py,sha256=-L39YexEkfaXszjc1-3Nc7MBtGZljS8_Z1t8KHE__1o,294
82
83
  boneio/models/logs.py,sha256=0IELpySgOv5BxqLZr_Q4p9jPbFcC8N0yvVccZIbeW3g,192
83
- boneio/mqtt_client.py,sha256=QsrfoFkh027_ZwNeiPJOhJ96gP8-csH4Ez4OA1RNSK4,9689
84
+ boneio/mqtt_client.py,sha256=l27iBoAOqG5iMAwBH_AnIFbeawB07NGHL1DG0ovskJw,9730
84
85
  boneio/oled.py,sha256=RAQInYUHyDq3Qe1VD03QBSiIz8UIzVfvh4h_t8aR4pU,11492
85
86
  boneio/relay/__init__.py,sha256=Cz6D37GKHxm8DiuPuxE2EMaey2wdUdJYVet_hfR0lzA,231
86
87
  boneio/relay/basic.py,sha256=oaSwSZhASfopmeyo8Ti1KRdw7o4w0CDAMw2fy9O2Jdc,5373
@@ -108,7 +109,7 @@ boneio/sensor/temp/__init__.py,sha256=XA0Jew4CJqyOCn06D6pXTELhT60885UaTxFdIqtXE-
108
109
  boneio/sensor/temp/dallas.py,sha256=qOhoZvBqgwDTy3Q7r1UUFbGoteUKMFsqpjBQgPm16rw,2690
109
110
  boneio/sensor/temp/lm75.py,sha256=-mpOv78429plRPBp9s09Ljz1x2Bdxuagalqz40vlAKE,243
110
111
  boneio/sensor/temp/mcp9808.py,sha256=yAh5yJzZLGTqa39xV4fyqsruj7oy3niOZAUV2W6eyCM,271
111
- boneio/version.py,sha256=hFc5nzKzhRB3ECxi8iXusf9NHuTCGShZNbWGN4KIw3s,41
112
+ boneio/version.py,sha256=z81Mox2_hiJJ34z3NEJn7GQoaVmX49eCPmL1UzgYTy4,41
112
113
  boneio/webui/app.py,sha256=JG6oi0QcQua4jk8uYpSXoDyhMCiLxx3WRzs9PLLOIKo,33323
113
114
  boneio/webui/frontend-dist/assets/abap-BrgZPUOV.js,sha256=o-KiQdqDx6qAg2rOn7OyokL0WP-Rffnxk2Py5kMN0Fk,14409
114
115
  boneio/webui/frontend-dist/assets/apex-DyP6w7ZV.js,sha256=nm1bQzOU_JCzp8WFFKtYxrtJ50DvA-FGkoo_0Ala62g,4198
@@ -229,8 +230,8 @@ boneio/webui/schema/sensor.schema.json,sha256=OGRunW_aAOfp2q0IU1aD3WRO7wEFsSknCl
229
230
  boneio/webui/schema/web.schema.json,sha256=hoixKf8J51D-UxGawcnD1UsgQFY07bqCQNereTaaNqw,1342
230
231
  boneio/webui/web_server.py,sha256=CDB19_yZpStAnrbFjucE7AN8i_pShMXjAbBCmNwdaCE,5102
231
232
  boneio/webui/websocket_manager.py,sha256=K9KXIT0OvK_ILNmM5GIH1f7FiYkk0vTNM0iJQh5Jdfg,5365
232
- boneio-0.9.4.dev2.dist-info/entry_points.txt,sha256=Igl1SMDEWwMg144bwRz28UOCb80hdxomC99QJ3u6qC0,46
233
- boneio-0.9.4.dev2.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
234
- boneio-0.9.4.dev2.dist-info/METADATA,sha256=A1tu94El04iuUEBv8BgUht4zGbt08gwaZQ0duUCtcbo,1977
235
- boneio-0.9.4.dev2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
236
- boneio-0.9.4.dev2.dist-info/RECORD,,
233
+ boneio-0.9.4.dev4.dist-info/entry_points.txt,sha256=Igl1SMDEWwMg144bwRz28UOCb80hdxomC99QJ3u6qC0,46
234
+ boneio-0.9.4.dev4.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
235
+ boneio-0.9.4.dev4.dist-info/METADATA,sha256=53He1zuA4dl4b6t8bjH3KZAsq0646kKuWSaxRGFkp1E,1977
236
+ boneio-0.9.4.dev4.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
237
+ boneio-0.9.4.dev4.dist-info/RECORD,,