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
k3mpaxl 2022-02-28 18:52:36 +01:00 committed by GitHub
parent f9616c2ae3
commit 430cdc6d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 6 deletions

View File

@ -28,6 +28,7 @@ from . import get_hub
from .base_platform import BaseStructPlatform
from .const import (
CALL_TYPE_REGISTER_HOLDING,
CALL_TYPE_WRITE_REGISTER,
CALL_TYPE_WRITE_REGISTERS,
CONF_CLIMATES,
CONF_MAX_TEMP,
@ -122,12 +123,21 @@ class ModbusThermostat(BaseStructPlatform, RestoreEntity, ClimateEntity):
for i in range(0, len(as_bytes), 2)
]
registers = self._swap_registers(raw_regs)
if isinstance(registers, list):
result = await self._hub.async_pymodbus_call(
self._slave,
self._target_temperature_register,
registers,
[int(float(i)) for i in 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
await self.async_update()