boneIO 0.8.0.dev15__tar.gz → 0.8.0.dev17__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.8.0.dev15 → boneIO-0.8.0.dev17}/PKG-INFO +1 -1
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/sensor.py +34 -32
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/single_sensor.py +5 -2
- boneIO-0.8.0.dev17/boneio/version.py +2 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/pyproject.toml +1 -1
- boneIO-0.8.0.dev15/boneio/version.py +0 -2
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/LICENSE +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/README.md +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/__init__.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/bonecli.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/const.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/cover.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/__init__.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/adc.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/binary_sensor.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/binary_sensor_v_0_7.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/config.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/cover.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/event.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/event_all.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/event_v_0_7.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/led32x4A.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/output24x16A.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/output24x16A_v0.3.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/output32x10A.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/example_config/output32x5A.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/fonts/danube__.ttf +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/group/__init__.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/group/output.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/__init__.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/async_updater.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/click_timer.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/config.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/events.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/exceptions.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/filter.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/gpio.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/gpiod.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/ha_discovery.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/loader.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/logger.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/mqtt.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/oled.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/onewire/W1ThermSensor.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/onewire/__init__.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/onewire/ds2482.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/onewire/onewire.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/pcf8575.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/queue.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/sensor/ina_219_smbus.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/state_manager.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/stats.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/timeperiod.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/util.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/helper/yaml_util.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/input/__init__.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/input/gpio.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/input/gpio_new.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/manager.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/__init__.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/client.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/cwt.json +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/dts1964_3f.json +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/liquid-sensor.json +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/modbuscli.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/orno-or-we-517.json +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/pt100.json +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/r4dcb08.json +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/sdm120.json +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/sdm630.json +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/sht20.json +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/socomec_e03.json +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/socomec_e23.json +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/sofar.json +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/modbus/utils.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/mqtt_client.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/oled.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/relay/__init__.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/relay/basic.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/relay/gpio.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/relay/mcp.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/relay/pca.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/relay/pcf.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/runner.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/schema/actions.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/schema/actions_sensor.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/schema/actions_switch.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/schema/filters.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/schema/filters_adc.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/schema/id.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/schema/schema.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/schema/temp_unit.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/schema/update_interval.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/sensor/__init__.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/sensor/adc.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/sensor/gpio.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/sensor/gpio_new.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/sensor/ina219.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/sensor/temp/__init__.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/sensor/temp/dallas.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/sensor/temp/lm75.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/boneio/sensor/temp/mcp9808.py +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/tests/32_5_config.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/tests/bandit.yaml +0 -0
- {boneIO-0.8.0.dev15 → boneIO-0.8.0.dev17}/tests/relay_32_5.py +0 -0
|
@@ -65,42 +65,42 @@ class ModbusSensor(BasicMqtt, AsyncUpdater, Filter):
|
|
|
65
65
|
k.lower(): v for k, v in sensors_filters.items()
|
|
66
66
|
}
|
|
67
67
|
self._modbus_sensors = []
|
|
68
|
-
for data in self._db[REGISTERS_BASE]:
|
|
68
|
+
for index, data in enumerate(self._db[REGISTERS_BASE]):
|
|
69
69
|
base = data[BASE]
|
|
70
|
+
self._modbus_sensors.append({})
|
|
70
71
|
for register in data[REGISTERS]:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
config_helper=self._config_helper,
|
|
93
|
-
ha_filter=register.get("ha_filter", "round(2)"),
|
|
94
|
-
),
|
|
72
|
+
single_sensor = SingleSensor(
|
|
73
|
+
name=register.get("name"),
|
|
74
|
+
parent={
|
|
75
|
+
NAME: self._name,
|
|
76
|
+
ID: self._id,
|
|
77
|
+
MODEL: self._model,
|
|
78
|
+
},
|
|
79
|
+
register_address=register[ADDRESS],
|
|
80
|
+
base_address=base,
|
|
81
|
+
unit_of_measurement=register.get("unit_of_measurement"),
|
|
82
|
+
state_class=register.get("state_class"),
|
|
83
|
+
device_class=register.get("device_class"),
|
|
84
|
+
value_type=register.get("value_type"),
|
|
85
|
+
return_type=register.get("return_type", "regular"),
|
|
86
|
+
filters=register.get("filters", []),
|
|
87
|
+
send_message=self._send_message,
|
|
88
|
+
config_helper=self._config_helper,
|
|
89
|
+
ha_filter=register.get("ha_filter", "round(2)"),
|
|
90
|
+
)
|
|
91
|
+
single_sensor.set_user_filters(
|
|
92
|
+
self._sensors_filters.get(single_sensor.decoded_name, [])
|
|
95
93
|
)
|
|
94
|
+
self._modbus_sensors[index][
|
|
95
|
+
single_sensor.decoded_name
|
|
96
|
+
] = single_sensor
|
|
96
97
|
event_bus.add_haonline_listener(target=self.set_payload_offline)
|
|
97
98
|
AsyncUpdater.__init__(self, **kwargs)
|
|
98
99
|
|
|
99
100
|
def get_sensor_by_name(self, name: str) -> Optional[SingleSensor]:
|
|
100
101
|
"""Return sensor by name."""
|
|
101
|
-
for
|
|
102
|
-
|
|
103
|
-
return sensor
|
|
102
|
+
for sensors in self._modbus_sensors:
|
|
103
|
+
return sensors.get(name)
|
|
104
104
|
return None
|
|
105
105
|
|
|
106
106
|
def set_payload_offline(self):
|
|
@@ -108,8 +108,9 @@ class ModbusSensor(BasicMqtt, AsyncUpdater, Filter):
|
|
|
108
108
|
|
|
109
109
|
def _send_discovery_for_all_registers(self) -> datetime:
|
|
110
110
|
"""Send discovery message to HA for each register."""
|
|
111
|
-
for
|
|
112
|
-
sensor.
|
|
111
|
+
for sensors in self._modbus_sensors:
|
|
112
|
+
for sensor in sensors.values():
|
|
113
|
+
sensor.send_ha_discovery()
|
|
113
114
|
return datetime.now()
|
|
114
115
|
|
|
115
116
|
async def check_availability(self) -> None:
|
|
@@ -147,7 +148,7 @@ class ModbusSensor(BasicMqtt, AsyncUpdater, Filter):
|
|
|
147
148
|
"""Fetch state periodically and send to MQTT."""
|
|
148
149
|
update_interval = self._update_interval.total_in_seconds
|
|
149
150
|
await self.check_availability()
|
|
150
|
-
for data in self._db[REGISTERS_BASE]:
|
|
151
|
+
for index, data in enumerate(self._db[REGISTERS_BASE]):
|
|
151
152
|
values = await self._modbus.read_registers(
|
|
152
153
|
unit=self._address,
|
|
153
154
|
address=data[BASE],
|
|
@@ -184,7 +185,8 @@ class ModbusSensor(BasicMqtt, AsyncUpdater, Filter):
|
|
|
184
185
|
elif update_interval != self._update_interval.total_in_seconds:
|
|
185
186
|
update_interval = self._update_interval.total_in_seconds
|
|
186
187
|
output = {}
|
|
187
|
-
|
|
188
|
+
current_modbus_sensors = self._modbus_sensors[index]
|
|
189
|
+
for sensor in current_modbus_sensors.values():
|
|
188
190
|
if not sensor.value_type:
|
|
189
191
|
# Go with old method. Remove when switch Sofar to new.
|
|
190
192
|
decoded_value = CONVERT_METHODS[sensor.return_type](
|
|
@@ -23,12 +23,12 @@ class SingleSensor(Filter):
|
|
|
23
23
|
device_class: str,
|
|
24
24
|
value_type: str,
|
|
25
25
|
return_type: str,
|
|
26
|
-
user_filters: list,
|
|
27
26
|
filters: list,
|
|
28
27
|
send_message: Callable[
|
|
29
28
|
[str, Union[str, int, dict, None], Optional[bool]], None
|
|
30
29
|
],
|
|
31
30
|
config_helper: ConfigHelper,
|
|
31
|
+
user_filters: Optional[list] = [],
|
|
32
32
|
ha_filter: str = "round(2)",
|
|
33
33
|
) -> None:
|
|
34
34
|
"""
|
|
@@ -67,6 +67,9 @@ class SingleSensor(Filter):
|
|
|
67
67
|
f"/{self._parent[ID]}{self._decoded_name_low.replace('_', '')}/config"
|
|
68
68
|
)
|
|
69
69
|
|
|
70
|
+
def set_user_filters(self, user_filters: list) -> None:
|
|
71
|
+
self._user_filters = user_filters
|
|
72
|
+
|
|
70
73
|
def set_value(self, value):
|
|
71
74
|
for filter in self._filters:
|
|
72
75
|
for key, _v in filter.items():
|
|
@@ -93,7 +96,7 @@ class SingleSensor(Filter):
|
|
|
93
96
|
|
|
94
97
|
def discovery_message(self):
|
|
95
98
|
value_template = (
|
|
96
|
-
f"{{{{ value_json.{self.
|
|
99
|
+
f"{{{{ value_json.{self.decoded_name} | " f"{self._ha_filter} }}}}"
|
|
97
100
|
)
|
|
98
101
|
kwargs = {
|
|
99
102
|
"unit_of_measurement": self._unit_of_measurement,
|
|
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
|
|
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
|