Update modbus climate (#62483)
Single register values weren't parsed accordingly for climate devices. Co-authored-by: jan Iversen <jancasacondor@gmail.com>pull/67392/head
parent
f9616c2ae3
commit
430cdc6d4c
|
@ -28,6 +28,7 @@ from . import get_hub
|
||||||
from .base_platform import BaseStructPlatform
|
from .base_platform import BaseStructPlatform
|
||||||
from .const import (
|
from .const import (
|
||||||
CALL_TYPE_REGISTER_HOLDING,
|
CALL_TYPE_REGISTER_HOLDING,
|
||||||
|
CALL_TYPE_WRITE_REGISTER,
|
||||||
CALL_TYPE_WRITE_REGISTERS,
|
CALL_TYPE_WRITE_REGISTERS,
|
||||||
CONF_CLIMATES,
|
CONF_CLIMATES,
|
||||||
CONF_MAX_TEMP,
|
CONF_MAX_TEMP,
|
||||||
|
@ -122,12 +123,21 @@ class ModbusThermostat(BaseStructPlatform, RestoreEntity, ClimateEntity):
|
||||||
for i in range(0, len(as_bytes), 2)
|
for i in range(0, len(as_bytes), 2)
|
||||||
]
|
]
|
||||||
registers = self._swap_registers(raw_regs)
|
registers = self._swap_registers(raw_regs)
|
||||||
|
|
||||||
|
if isinstance(registers, list):
|
||||||
result = await self._hub.async_pymodbus_call(
|
result = await self._hub.async_pymodbus_call(
|
||||||
self._slave,
|
self._slave,
|
||||||
self._target_temperature_register,
|
self._target_temperature_register,
|
||||||
registers,
|
[int(float(i)) for i in registers],
|
||||||
CALL_TYPE_WRITE_REGISTERS,
|
CALL_TYPE_WRITE_REGISTERS,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
result = await self._hub.async_pymodbus_call(
|
||||||
|
self._slave,
|
||||||
|
self._target_temperature_register,
|
||||||
|
target_temperature,
|
||||||
|
CALL_TYPE_WRITE_REGISTER,
|
||||||
|
)
|
||||||
self._attr_available = result is not None
|
self._attr_available = result is not None
|
||||||
await self.async_update()
|
await self.async_update()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue