boneIO 0.8.0.dev5__tar.gz → 0.8.0.dev6__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.dev5 → boneIO-0.8.0.dev6}/PKG-INFO +1 -1
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/client.py +22 -22
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/modbuscli.py +2 -2
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/sensor.py +5 -2
- boneIO-0.8.0.dev6/boneio/version.py +2 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/pyproject.toml +1 -1
- boneIO-0.8.0.dev5/boneio/version.py +0 -2
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/LICENSE +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/README.md +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/__init__.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/bonecli.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/const.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/cover.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/example_config/__init__.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/example_config/adc.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/example_config/binary_sensor.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/example_config/config.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/example_config/cover.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/example_config/event.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/example_config/event_all.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/example_config/led32x4A.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/example_config/output24x16A.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/example_config/output24x16A_v0.3.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/example_config/output32x5A.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/fonts/danube__.ttf +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/group/__init__.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/group/output.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/__init__.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/async_updater.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/click_timer.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/config.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/events.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/exceptions.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/filter.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/gpio.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/ha_discovery.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/loader.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/logger.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/mqtt.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/oled.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/onewire/W1ThermSensor.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/onewire/__init__.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/onewire/ds2482.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/onewire/onewire.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/pcf8575.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/queue.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/sensor/ina_219_smbus.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/state_manager.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/stats.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/timeperiod.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/util.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/helper/yaml_util.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/input/__init__.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/input/gpio.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/input/gpio_new.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/manager.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/__init__.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/cwt.json +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/dts1964_3f.json +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/orno-or-we-517.json +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/pt100.json +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/r4dcb08.json +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/sdm120.json +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/sdm630.json +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/socomec_e23.json +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/sofar.json +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/modbus/utils.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/mqtt_client.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/oled.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/relay/__init__.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/relay/basic.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/relay/gpio.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/relay/mcp.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/relay/pca.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/relay/pcf.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/runner.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/schema/actions.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/schema/actions_sensor.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/schema/actions_switch.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/schema/filters.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/schema/filters_adc.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/schema/id.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/schema/schema.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/schema/temp_unit.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/schema/update_interval.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/sensor/__init__.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/sensor/adc.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/sensor/gpio.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/sensor/gpio_new.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/sensor/ina219.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/sensor/temp/__init__.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/sensor/temp/dallas.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/sensor/temp/lm75.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/boneio/sensor/temp/mcp9808.py +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/tests/32_5_config.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/tests/bandit.yaml +0 -0
- {boneIO-0.8.0.dev5 → boneIO-0.8.0.dev6}/tests/relay_32_5.py +0 -0
|
@@ -101,34 +101,26 @@ class Modbus:
|
|
|
101
101
|
_LOGGER.error(exception_error)
|
|
102
102
|
return False
|
|
103
103
|
|
|
104
|
-
async def
|
|
104
|
+
async def read_and_decode(
|
|
105
105
|
self,
|
|
106
106
|
unit: int | str,
|
|
107
107
|
address: int,
|
|
108
|
+
payload_type: str,
|
|
108
109
|
count: int = 2,
|
|
109
110
|
method: str = "input",
|
|
110
111
|
) -> float | None:
|
|
111
112
|
"""Call sync. pymodbus."""
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
except (ModbusException, struct.error) as exception_error:
|
|
122
|
-
_LOGGER.error(exception_error)
|
|
123
|
-
return None
|
|
124
|
-
if not hasattr(result, REGISTERS):
|
|
125
|
-
_LOGGER.error(str(result))
|
|
126
|
-
return None
|
|
127
|
-
return BinaryPayloadDecoder.fromRegisters(
|
|
128
|
-
result.registers, byteorder=Endian.Big, wordorder=Endian.Big
|
|
129
|
-
).decode_32bit_float()
|
|
113
|
+
result = await self.read_registers(
|
|
114
|
+
unit=unit, address=address, count=count, method=method
|
|
115
|
+
)
|
|
116
|
+
if not result or result.isError():
|
|
117
|
+
return None
|
|
118
|
+
decoded_value = self.decode_value(
|
|
119
|
+
payload=result.registers, value_type=payload_type
|
|
120
|
+
)
|
|
121
|
+
return decoded_value
|
|
130
122
|
|
|
131
|
-
async def
|
|
123
|
+
async def read_registers(
|
|
132
124
|
self,
|
|
133
125
|
unit: int | str, # device address
|
|
134
126
|
address: int, # modbus register address
|
|
@@ -142,10 +134,18 @@ class Modbus:
|
|
|
142
134
|
return None
|
|
143
135
|
kwargs = {"unit": unit, "count": count} if unit else {}
|
|
144
136
|
try:
|
|
145
|
-
|
|
137
|
+
read_method = self._read_methods[method]
|
|
138
|
+
_LOGGER.debug(
|
|
139
|
+
"Multiple reading %s registers from %s with method %s from device %s.",
|
|
140
|
+
count,
|
|
141
|
+
address,
|
|
142
|
+
method,
|
|
143
|
+
unit,
|
|
144
|
+
)
|
|
145
|
+
result: ReadInputRegistersResponse = read_method(
|
|
146
146
|
address, **kwargs
|
|
147
147
|
)
|
|
148
|
-
except ModbusException as exception_error:
|
|
148
|
+
except (ModbusException, struct.error) as exception_error:
|
|
149
149
|
_LOGGER.error(exception_error)
|
|
150
150
|
return None
|
|
151
151
|
if not hasattr(result, REGISTERS):
|
|
@@ -53,7 +53,7 @@ class ModbusHelper:
|
|
|
53
53
|
f"Checking connection {self._device_address}, address {address}."
|
|
54
54
|
)
|
|
55
55
|
count = 1 if value_type == "S_WORD" or value_type == "U_WORD" else 2
|
|
56
|
-
value = await self._modbus.
|
|
56
|
+
value = await self._modbus.read_registers(
|
|
57
57
|
unit=self._device_address,
|
|
58
58
|
address=address,
|
|
59
59
|
count=count,
|
|
@@ -180,7 +180,7 @@ async def async_run_modbus_get(
|
|
|
180
180
|
parity=parity,
|
|
181
181
|
)
|
|
182
182
|
count = 1 if value_type == "S_WORD" or value_type == "U_WORD" else 2
|
|
183
|
-
value = await _modbus.
|
|
183
|
+
value = await _modbus.read_registers(
|
|
184
184
|
unit=device_address,
|
|
185
185
|
address=register_address,
|
|
186
186
|
count=count,
|
|
@@ -122,10 +122,13 @@ class ModbusSensor(BasicMqtt, AsyncUpdater):
|
|
|
122
122
|
register_method = first_register_base.get("register_type", "input")
|
|
123
123
|
# Let's try fetch register 2 times in case something wrong with initial packet.
|
|
124
124
|
for _ in [0, 1]:
|
|
125
|
-
register = await self._modbus.
|
|
125
|
+
register = await self._modbus.read_and_decode(
|
|
126
126
|
unit=self._address,
|
|
127
127
|
address=first_register_base[REGISTERS][0][ADDRESS],
|
|
128
128
|
method=register_method,
|
|
129
|
+
payload_type=first_register_base[REGISTERS][0].get(
|
|
130
|
+
"value_type", "FP32"
|
|
131
|
+
),
|
|
129
132
|
)
|
|
130
133
|
if register is not None:
|
|
131
134
|
self._discovery_sent = (
|
|
@@ -144,7 +147,7 @@ class ModbusSensor(BasicMqtt, AsyncUpdater):
|
|
|
144
147
|
update_interval = self._update_interval.total_in_seconds
|
|
145
148
|
await self.check_availability()
|
|
146
149
|
for data in self._db[REGISTERS_BASE]:
|
|
147
|
-
values = await self._modbus.
|
|
150
|
+
values = await self._modbus.read_registers(
|
|
148
151
|
unit=self._address,
|
|
149
152
|
address=data[BASE],
|
|
150
153
|
count=data[LENGTH],
|
|
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
|