Simplify code, due to better error catching in modbus. (#100483)
This commit is contained in:
parent
30d604c851
commit
48dc81eff0
4 changed files with 2 additions and 15 deletions
|
@ -122,10 +122,7 @@ class ModbusBinarySensor(BasePlatform, RestoreEntity, BinarySensorEntity):
|
|||
self._result = result.bits
|
||||
else:
|
||||
self._result = result.registers
|
||||
if len(self._result) >= 1:
|
||||
self._attr_is_on = bool(self._result[0] & 1)
|
||||
else:
|
||||
self._attr_available = False
|
||||
|
||||
self.async_write_ha_state()
|
||||
if self._coordinator:
|
||||
|
|
|
@ -247,10 +247,6 @@ class ModbusThermostat(BaseStructPlatform, RestoreEntity, ClimateEntity):
|
|||
# remark "now" is a dummy parameter to avoid problems with
|
||||
# async_track_time_interval
|
||||
|
||||
# do not allow multiple active calls to the same platform
|
||||
if self._call_active:
|
||||
return
|
||||
self._call_active = True
|
||||
self._attr_target_temperature = await self._async_read_register(
|
||||
CALL_TYPE_REGISTER_HOLDING, self._target_temperature_register
|
||||
)
|
||||
|
@ -282,7 +278,6 @@ class ModbusThermostat(BaseStructPlatform, RestoreEntity, ClimateEntity):
|
|||
if onoff == 0:
|
||||
self._attr_hvac_mode = HVACMode.OFF
|
||||
|
||||
self._call_active = False
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def _async_read_register(
|
||||
|
|
|
@ -138,14 +138,9 @@ class ModbusCover(BasePlatform, CoverEntity, RestoreEntity):
|
|||
"""Update the state of the cover."""
|
||||
# remark "now" is a dummy parameter to avoid problems with
|
||||
# async_track_time_interval
|
||||
# do not allow multiple active calls to the same platform
|
||||
if self._call_active:
|
||||
return
|
||||
self._call_active = True
|
||||
result = await self._hub.async_pb_call(
|
||||
self._slave, self._address, 1, self._input_type
|
||||
)
|
||||
self._call_active = False
|
||||
if result is None:
|
||||
if self._lazy_errors:
|
||||
self._lazy_errors -= 1
|
||||
|
|
|
@ -261,7 +261,7 @@ class ModbusHub:
|
|||
"""Initialize the Modbus hub."""
|
||||
|
||||
if CONF_CLOSE_COMM_ON_ERROR in client_config:
|
||||
async_create_issue( # pragma: no cover
|
||||
async_create_issue(
|
||||
hass,
|
||||
DOMAIN,
|
||||
"deprecated_close_comm_config",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue