boneIO 0.3.0.dev8__tar.gz → 0.3.0.dev9__tar.gz
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.
- {boneio-0.3.0.dev8/boneio.egg-info → boneio-0.3.0.dev9}/PKG-INFO +2 -2
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/events.py +10 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/loader.py +2 -8
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/manager.py +2 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/sensor/modbus/__init__.py +13 -8
- boneio-0.3.0.dev9/boneio/version.py +2 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9/boneio.egg-info}/PKG-INFO +2 -2
- boneio-0.3.0.dev8/boneio/version.py +0 -2
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/LICENSE +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/MANIFEST.in +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/README.md +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/__init__.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/bonecli.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/const.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/cover.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/example_config/__init__.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/example_config/adc.yaml +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/example_config/config.yaml +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/example_config/cover.yaml +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/example_config/input.yaml +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/example_config/output24x16A.yaml +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/example_config/output32x5A.yaml +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/fonts/danube__.ttf +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/__init__.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/config.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/ds2482/__init__.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/ds2482/ds2482.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/ds2482/onewire.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/exceptions.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/gpio.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/ha_discovery.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/logger.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/mqtt.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/oled.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/queue.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/state_manager.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/stats.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/timeperiod.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/util.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/helper/yaml_util.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/input/__init__.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/input/gpio.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/modbus.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/mqtt_client.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/oled.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/relay/__init__.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/relay/basic.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/relay/gpio.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/relay/mcp.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/runner.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/schema/actions.yaml +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/schema/actions_sensor.yaml +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/schema/actions_switch.yaml +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/schema/schema.yaml +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/sensor/__init__.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/sensor/adc.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/sensor/gpio.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/sensor/modbus/sdm120.json +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/sensor/modbus/sdm630.json +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/sensor/modbus/sofar.json +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/sensor/temp/__init__.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/sensor/temp/dallas.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/sensor/temp/lm75.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio/sensor/temp/mcp9808.py +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio.egg-info/SOURCES.txt +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio.egg-info/dependency_links.txt +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio.egg-info/entry_points.txt +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio.egg-info/requires.txt +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/boneio.egg-info/top_level.txt +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/requirements.txt +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/setup.cfg +0 -0
- {boneio-0.3.0.dev8 → boneio-0.3.0.dev9}/setup.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: boneio
|
|
3
|
-
Version: 0.3.0.
|
|
3
|
+
Version: 0.3.0.dev9
|
|
4
4
|
Summary: Python App for BoneIO
|
|
5
5
|
Home-page: https://github.com/boneIO-eu/app_bbb
|
|
6
|
-
Download-URL: https://github.com/boneIO-eu/app_bbb/archive/0.3.0.
|
|
6
|
+
Download-URL: https://github.com/boneIO-eu/app_bbb/archive/0.3.0.dev9.zip
|
|
7
7
|
License: GNU General Public License v3.0
|
|
8
8
|
Platform: UNKNOWN
|
|
9
9
|
Classifier: Programming Language :: Python
|
|
@@ -79,6 +79,7 @@ class EventBus:
|
|
|
79
79
|
self._loop = loop or asyncio.get_event_loop()
|
|
80
80
|
self._listeners = {}
|
|
81
81
|
self._sigterm_listeners = []
|
|
82
|
+
self._haonline_listeners = []
|
|
82
83
|
self._timer_handle = _async_create_timer(self._loop, self._run_second_event)
|
|
83
84
|
for signame in {"SIGINT", "SIGTERM"}:
|
|
84
85
|
self._loop.add_signal_handler(
|
|
@@ -113,6 +114,15 @@ class EventBus:
|
|
|
113
114
|
"""Add sigterm listener."""
|
|
114
115
|
self._sigterm_listeners.append(target)
|
|
115
116
|
|
|
117
|
+
def add_haonline_listener(self, target):
|
|
118
|
+
"""Add HA Online listener."""
|
|
119
|
+
self._haonline_listeners.append(target)
|
|
120
|
+
|
|
121
|
+
def signal_ha_online(self):
|
|
122
|
+
"""Call events if HA goes online."""
|
|
123
|
+
for target in self._haonline_listeners:
|
|
124
|
+
target()
|
|
125
|
+
|
|
116
126
|
def remove_listener(self, name):
|
|
117
127
|
"""Remove regular listener."""
|
|
118
128
|
if name in self._listeners:
|
|
@@ -156,12 +156,7 @@ def create_mcp23017(
|
|
|
156
156
|
return grouped_outputs
|
|
157
157
|
|
|
158
158
|
|
|
159
|
-
def create_modbus_sensors(
|
|
160
|
-
manager: Manager,
|
|
161
|
-
config_helper: ConfigHelper,
|
|
162
|
-
modbus: Modbus,
|
|
163
|
-
sensors,
|
|
164
|
-
) -> None:
|
|
159
|
+
def create_modbus_sensors(manager: Manager, sensors, **kwargs) -> None:
|
|
165
160
|
"""Create Modbus sensor for each device."""
|
|
166
161
|
from boneio.sensor.modbus import ModbusSensor
|
|
167
162
|
|
|
@@ -170,14 +165,13 @@ def create_modbus_sensors(
|
|
|
170
165
|
id = name.replace(" ", "")
|
|
171
166
|
try:
|
|
172
167
|
sdm = ModbusSensor(
|
|
173
|
-
modbus=modbus,
|
|
174
168
|
address=sensor[ADDRESS],
|
|
175
169
|
id=id,
|
|
176
170
|
name=name,
|
|
177
171
|
model=sensor[MODEL],
|
|
178
172
|
send_message=manager.send_message,
|
|
179
|
-
config_helper=config_helper,
|
|
180
173
|
update_interval=sensor.get(UPDATE_INTERVAL, TimePeriod(seconds=60)),
|
|
174
|
+
**kwargs,
|
|
181
175
|
)
|
|
182
176
|
manager.append_task(asyncio.create_task(sdm.send_state()))
|
|
183
177
|
except FileNotFoundError as err:
|
|
@@ -135,6 +135,7 @@ class Manager:
|
|
|
135
135
|
|
|
136
136
|
create_modbus_sensors(
|
|
137
137
|
manager=self,
|
|
138
|
+
event_bus=self._event_bus,
|
|
138
139
|
sensors=sensors.get(MODBUS),
|
|
139
140
|
modbus=self._modbus,
|
|
140
141
|
config_helper=self._config_helper,
|
|
@@ -398,6 +399,7 @@ class Manager:
|
|
|
398
399
|
if topic.startswith(f"{self._config_helper.ha_discovery_prefix}/status"):
|
|
399
400
|
if message == ONLINE:
|
|
400
401
|
self.resend_autodiscovery()
|
|
402
|
+
self._event_bus.signal_ha_online()
|
|
401
403
|
return
|
|
402
404
|
assert topic.startswith(self._config_helper.cmd_topic_prefix)
|
|
403
405
|
topic_parts_raw = topic[len(self._config_helper.cmd_topic_prefix) :].split("/")
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from distutils.command.config import config
|
|
2
1
|
import logging
|
|
3
2
|
import asyncio
|
|
4
3
|
from datetime import datetime
|
|
@@ -23,7 +22,7 @@ from boneio.helper.ha_discovery import modbus_sensor_availabilty_message
|
|
|
23
22
|
from boneio.helper.timeperiod import TimePeriod
|
|
24
23
|
from boneio.helper.config import ConfigHelper
|
|
25
24
|
from boneio.modbus import Modbus
|
|
26
|
-
|
|
25
|
+
from boneio.helper.events import EventBus
|
|
27
26
|
|
|
28
27
|
_LOGGER = logging.getLogger(__name__)
|
|
29
28
|
|
|
@@ -98,6 +97,7 @@ class ModbusSensor(BasicMqtt):
|
|
|
98
97
|
address: str,
|
|
99
98
|
model: str,
|
|
100
99
|
config_helper: ConfigHelper,
|
|
100
|
+
event_bus: EventBus,
|
|
101
101
|
id: str = DefaultName,
|
|
102
102
|
update_interval: TimePeriod = TimePeriod(seconds=60),
|
|
103
103
|
**kwargs,
|
|
@@ -116,6 +116,11 @@ class ModbusSensor(BasicMqtt):
|
|
|
116
116
|
self._address = address
|
|
117
117
|
self._discovery_sent = False
|
|
118
118
|
self._update_interval = update_interval
|
|
119
|
+
self._payload_online = OFFLINE
|
|
120
|
+
event_bus.add_haonline_listener(target=self.set_payload_offline)
|
|
121
|
+
|
|
122
|
+
def set_payload_offline(self):
|
|
123
|
+
self._payload_online = OFFLINE
|
|
119
124
|
|
|
120
125
|
def _send_ha_autodiscovery(
|
|
121
126
|
self, id: str, sdm_name: str, sensor_id: str, **kwargs
|
|
@@ -190,7 +195,7 @@ class ModbusSensor(BasicMqtt):
|
|
|
190
195
|
async def send_state(self) -> None:
|
|
191
196
|
"""Fetch state periodically and send to MQTT."""
|
|
192
197
|
update_interval = self._update_interval.total_seconds
|
|
193
|
-
|
|
198
|
+
self.set_payload_offline()
|
|
194
199
|
while True:
|
|
195
200
|
await self.check_availability()
|
|
196
201
|
for data in self._db[REGISTERS_BASE]:
|
|
@@ -200,12 +205,12 @@ class ModbusSensor(BasicMqtt):
|
|
|
200
205
|
count=data[LENGTH],
|
|
201
206
|
method=data.get("register_type", "input"),
|
|
202
207
|
)
|
|
203
|
-
if
|
|
208
|
+
if self._payload_online == OFFLINE and values:
|
|
204
209
|
_LOGGER.info("Sending online payload about device.")
|
|
205
|
-
|
|
210
|
+
self._payload_online = ONLINE
|
|
206
211
|
self._send_message(
|
|
207
212
|
topic=f"{self._config_helper.topic_prefix}/{self._id}{STATE}",
|
|
208
|
-
payload=
|
|
213
|
+
payload=self._payload_online,
|
|
209
214
|
)
|
|
210
215
|
if not values:
|
|
211
216
|
if update_interval < 600:
|
|
@@ -213,10 +218,10 @@ class ModbusSensor(BasicMqtt):
|
|
|
213
218
|
update_interval = update_interval * 1.5
|
|
214
219
|
else:
|
|
215
220
|
# Let's assume device is offline.
|
|
216
|
-
|
|
221
|
+
self.set_payload_offline()
|
|
217
222
|
self._send_message(
|
|
218
223
|
topic=f"{self._config_helper.topic_prefix}/{self._id}{STATE}",
|
|
219
|
-
payload=
|
|
224
|
+
payload=self._payload_online,
|
|
220
225
|
)
|
|
221
226
|
_LOGGER.warn(
|
|
222
227
|
"Can't fetch data from modbus device. Will sleep for %s seconds",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: boneio
|
|
3
|
-
Version: 0.3.0.
|
|
3
|
+
Version: 0.3.0.dev9
|
|
4
4
|
Summary: Python App for BoneIO
|
|
5
5
|
Home-page: https://github.com/boneIO-eu/app_bbb
|
|
6
|
-
Download-URL: https://github.com/boneIO-eu/app_bbb/archive/0.3.0.
|
|
6
|
+
Download-URL: https://github.com/boneIO-eu/app_bbb/archive/0.3.0.dev9.zip
|
|
7
7
|
License: GNU General Public License v3.0
|
|
8
8
|
Platform: UNKNOWN
|
|
9
9
|
Classifier: Programming Language :: Python
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|