Update modbus state when sensor fails (#49481)

This commit is contained in:
jan iversen 2021-04-20 14:54:20 +02:00 committed by GitHub
parent bc5add82e0
commit c14e525ac3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 0 deletions

View file

@ -619,6 +619,7 @@ omit =
homeassistant/components/modbus/modbus.py
homeassistant/components/modbus/switch.py
homeassistant/components/modbus/sensor.py
homeassistant/components/modbus/binary_sensor.py
homeassistant/components/modem_callerid/sensor.py
homeassistant/components/motion_blinds/__init__.py
homeassistant/components/motion_blinds/const.py

View file

@ -170,6 +170,7 @@ class ModbusBinarySensor(BinarySensorEntity):
result = self._hub.read_discrete_inputs(self._slave, self._address, 1)
if result is None:
self._available = False
self.schedule_update_ha_state()
return
self._value = result.bits[0] & 1

View file

@ -294,6 +294,7 @@ class ModbusRegisterSensor(RestoreEntity, SensorEntity):
)
if result is None:
self._available = False
self.schedule_update_ha_state()
return
registers = result.registers