diff --git a/homeassistant/components/modbus/binary_sensor.py b/homeassistant/components/modbus/binary_sensor.py index 4f416874f9d..43f43585775 100644 --- a/homeassistant/components/modbus/binary_sensor.py +++ b/homeassistant/components/modbus/binary_sensor.py @@ -115,7 +115,10 @@ class ModbusBinarySensor(BasePlatform, RestoreEntity, BinarySensorEntity): self._result = result.bits else: self._result = result.registers - self._attr_is_on = bool(self._result[0] & 1) + 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: diff --git a/homeassistant/components/modbus/manifest.json b/homeassistant/components/modbus/manifest.json index bb64a264248..c2e6b9ef467 100644 --- a/homeassistant/components/modbus/manifest.json +++ b/homeassistant/components/modbus/manifest.json @@ -6,5 +6,5 @@ "iot_class": "local_polling", "loggers": ["pymodbus"], "quality_scale": "gold", - "requirements": ["pymodbus==3.1.3"] + "requirements": ["pymodbus==3.3.1"] } diff --git a/requirements_all.txt b/requirements_all.txt index 55225b9bfb5..2588f88fe0f 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1829,7 +1829,7 @@ pymitv==1.4.3 pymochad==0.2.0 # homeassistant.components.modbus -pymodbus==3.1.3 +pymodbus==3.3.1 # homeassistant.components.monoprice pymonoprice==0.4 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 1b7103467ec..310a50ec9c3 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1348,7 +1348,7 @@ pymeteoclimatic==0.0.6 pymochad==0.2.0 # homeassistant.components.modbus -pymodbus==3.1.3 +pymodbus==3.3.1 # homeassistant.components.monoprice pymonoprice==0.4 diff --git a/tests/components/modbus/test_init.py b/tests/components/modbus/test_init.py index 7a069234045..2daf722bb05 100644 --- a/tests/components/modbus/test_init.py +++ b/tests/components/modbus/test_init.py @@ -705,7 +705,6 @@ async def test_pymodbus_connect_fail( ExceptionMessage = "test connect exception" mock_pymodbus.connect.side_effect = ModbusException(ExceptionMessage) assert await async_setup_component(hass, DOMAIN, config) is True - assert ExceptionMessage in caplog.text async def test_delay(