diff --git a/homeassistant/components/vera/__init__.py b/homeassistant/components/vera/__init__.py index 3fd1c189b63647b8626b36fd79c44bc5f0951450..4bfa72b5eb648d052c266698eb6f4172105491c7 100644 --- a/homeassistant/components/vera/__init__.py +++ b/homeassistant/components/vera/__init__.py @@ -232,6 +232,11 @@ class VeraDevice(Generic[DeviceType], Entity): """Update the state.""" self.schedule_update_ha_state(True) + def update(self): + """Force a refresh from the device if the device is unavailable.""" + if not self.available: + self.vera_device.refresh() + @property def name(self) -> str: """Return the name of the device.""" @@ -276,6 +281,11 @@ class VeraDevice(Generic[DeviceType], Entity): return attr + @property + def available(self): + """If device communications have failed return false.""" + return not self.vera_device.comm_failure + @property def unique_id(self) -> str: """Return a unique ID. diff --git a/homeassistant/components/vera/binary_sensor.py b/homeassistant/components/vera/binary_sensor.py index 7932fa14f4c3ece0558740ca2d55c9bf31d24d41..00d4fb3a75827da23b2e03140d0f9171fa4c1faf 100644 --- a/homeassistant/components/vera/binary_sensor.py +++ b/homeassistant/components/vera/binary_sensor.py @@ -50,4 +50,5 @@ class VeraBinarySensor(VeraDevice[veraApi.VeraBinarySensor], BinarySensorEntity) def update(self) -> None: """Get the latest data and update the state.""" + super().update() self._state = self.vera_device.is_tripped diff --git a/homeassistant/components/vera/light.py b/homeassistant/components/vera/light.py index c52627d340f6639556a9298561c0c0f74367011c..30c4e93a2ba7d3845c769afadd5154f7f9b2966f 100644 --- a/homeassistant/components/vera/light.py +++ b/homeassistant/components/vera/light.py @@ -93,6 +93,7 @@ class VeraLight(VeraDevice[veraApi.VeraDimmer], LightEntity): def update(self) -> None: """Call to update state.""" + super().update() self._state = self.vera_device.is_switched_on() if self.vera_device.is_dimmable: # If it is dimmable, both functions exist. In case color diff --git a/homeassistant/components/vera/manifest.json b/homeassistant/components/vera/manifest.json index 264f44782f5fb61f29d61dcf869b1c74e86d2347..1f180b397500719dd495653de368a71adab6a967 100644 --- a/homeassistant/components/vera/manifest.json +++ b/homeassistant/components/vera/manifest.json @@ -3,6 +3,6 @@ "name": "Vera", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/vera", - "requirements": ["pyvera==0.3.11"], + "requirements": ["pyvera==0.3.13"], "codeowners": ["@vangorra"] } diff --git a/homeassistant/components/vera/sensor.py b/homeassistant/components/vera/sensor.py index ea7dbf0ae30d3a383daadd6c8179bb7f808ad725..007290807e691f60b05ee8109206ec15391f6c5d 100644 --- a/homeassistant/components/vera/sensor.py +++ b/homeassistant/components/vera/sensor.py @@ -68,7 +68,7 @@ class VeraSensor(VeraDevice[veraApi.VeraSensor], Entity): def update(self) -> None: """Update the state.""" - + super().update() if self.vera_device.category == veraApi.CATEGORY_TEMPERATURE_SENSOR: self.current_value = self.vera_device.temperature diff --git a/homeassistant/components/vera/switch.py b/homeassistant/components/vera/switch.py index 5dfeba6f5b2bd67ba17ab4889cce58ad3a069985..f567893e5b0f5ec31b183bad61f120373264014e 100644 --- a/homeassistant/components/vera/switch.py +++ b/homeassistant/components/vera/switch.py @@ -70,4 +70,5 @@ class VeraSwitch(VeraDevice[veraApi.VeraSwitch], SwitchEntity): def update(self) -> None: """Update device state.""" + super().update() self._state = self.vera_device.is_switched_on() diff --git a/requirements_all.txt b/requirements_all.txt index 04dbcdf9d1ac67680a4aac926faf690b242c58a3..6a8b5f63fa280b6bfa793d2dadd0362b61f7387d 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1880,7 +1880,7 @@ pyuptimerobot==0.0.5 # pyuserinput==0.1.11 # homeassistant.components.vera -pyvera==0.3.11 +pyvera==0.3.13 # homeassistant.components.versasense pyversasense==0.0.6 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 548d6ba1117cff5847b86db6dc5ad7d6fcfea75c..54f6651ad0cf1074cc718c11583a568868b68983 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -953,7 +953,7 @@ pytraccar==0.9.0 pytradfri[async]==7.0.6 # homeassistant.components.vera -pyvera==0.3.11 +pyvera==0.3.13 # homeassistant.components.vesync pyvesync==1.2.0 diff --git a/tests/components/vera/test_binary_sensor.py b/tests/components/vera/test_binary_sensor.py index 1bcb8d1a1834969d38ca03008f1e3b0821b09160..b3b8d2d6ae194c293e679edee04d968e6b1f72bd 100644 --- a/tests/components/vera/test_binary_sensor.py +++ b/tests/components/vera/test_binary_sensor.py @@ -14,6 +14,7 @@ async def test_binary_sensor( """Test function.""" vera_device = MagicMock(spec=pv.VeraBinarySensor) # type: pv.VeraBinarySensor vera_device.device_id = 1 + vera_device.comm_failure = False vera_device.vera_device_id = vera_device.device_id vera_device.name = "dev1" vera_device.is_tripped = False diff --git a/tests/components/vera/test_climate.py b/tests/components/vera/test_climate.py index 076b51997a0e63ead25f4f366bf01cd22341d8f1..5ec39f07953710814d6f8ce75647d4becffd4da7 100644 --- a/tests/components/vera/test_climate.py +++ b/tests/components/vera/test_climate.py @@ -23,6 +23,7 @@ async def test_climate( vera_device = MagicMock(spec=pv.VeraThermostat) # type: pv.VeraThermostat vera_device.device_id = 1 vera_device.vera_device_id = vera_device.device_id + vera_device.comm_failure = False vera_device.name = "dev1" vera_device.category = pv.CATEGORY_THERMOSTAT vera_device.power = 10 @@ -133,6 +134,7 @@ async def test_climate_f( vera_device = MagicMock(spec=pv.VeraThermostat) # type: pv.VeraThermostat vera_device.device_id = 1 vera_device.vera_device_id = vera_device.device_id + vera_device.comm_failure = False vera_device.name = "dev1" vera_device.category = pv.CATEGORY_THERMOSTAT vera_device.power = 10 diff --git a/tests/components/vera/test_cover.py b/tests/components/vera/test_cover.py index 0c05d84e2dbc1da1870ca0e33b1dc232e9de298f..cfc33fb2dcfcc5d4e81c9720ef2ec1243e2c3410 100644 --- a/tests/components/vera/test_cover.py +++ b/tests/components/vera/test_cover.py @@ -15,6 +15,7 @@ async def test_cover( vera_device = MagicMock(spec=pv.VeraCurtain) # type: pv.VeraCurtain vera_device.device_id = 1 vera_device.vera_device_id = vera_device.device_id + vera_device.comm_failure = False vera_device.name = "dev1" vera_device.category = pv.CATEGORY_CURTAIN vera_device.is_closed = False diff --git a/tests/components/vera/test_light.py b/tests/components/vera/test_light.py index 3b14aba742992ca367a943b58cc0d2b9425c5e3f..ad5ad7e0259952ae0313023cf72f8c05a39d0179 100644 --- a/tests/components/vera/test_light.py +++ b/tests/components/vera/test_light.py @@ -16,6 +16,7 @@ async def test_light( vera_device = MagicMock(spec=pv.VeraDimmer) # type: pv.VeraDimmer vera_device.device_id = 1 vera_device.vera_device_id = vera_device.device_id + vera_device.comm_failure = False vera_device.name = "dev1" vera_device.category = pv.CATEGORY_DIMMER vera_device.is_switched_on = MagicMock(return_value=False) diff --git a/tests/components/vera/test_lock.py b/tests/components/vera/test_lock.py index c288ac8709e1ab357148a807cf01810877f1f2e1..171f799f87bae6fcc984576371b1d0eb10c92aa5 100644 --- a/tests/components/vera/test_lock.py +++ b/tests/components/vera/test_lock.py @@ -16,6 +16,7 @@ async def test_lock( vera_device = MagicMock(spec=pv.VeraLock) # type: pv.VeraLock vera_device.device_id = 1 vera_device.vera_device_id = vera_device.device_id + vera_device.comm_failure = False vera_device.name = "dev1" vera_device.category = pv.CATEGORY_LOCK vera_device.is_locked = MagicMock(return_value=False) diff --git a/tests/components/vera/test_sensor.py b/tests/components/vera/test_sensor.py index 437776428164a5dd54bc2019b22fcb7e4f9bf135..62639df3a35ae46c1e7bcc2a76c6efb68144ff7b 100644 --- a/tests/components/vera/test_sensor.py +++ b/tests/components/vera/test_sensor.py @@ -23,6 +23,7 @@ async def run_sensor_test( vera_device = MagicMock(spec=pv.VeraSensor) # type: pv.VeraSensor vera_device.device_id = 1 vera_device.vera_device_id = vera_device.device_id + vera_device.comm_failure = False vera_device.name = "dev1" vera_device.category = category setattr(vera_device, class_property, "33") @@ -178,6 +179,7 @@ async def test_scene_controller_sensor( vera_device = MagicMock(spec=pv.VeraSensor) # type: pv.VeraSensor vera_device.device_id = 1 vera_device.vera_device_id = vera_device.device_id + vera_device.comm_failure = False vera_device.name = "dev1" vera_device.category = pv.CATEGORY_SCENE_CONTROLLER vera_device.get_last_scene_id = MagicMock(return_value="id0") diff --git a/tests/components/vera/test_switch.py b/tests/components/vera/test_switch.py index b61564c56bc5779115607d03456e94059e8e8fb6..ac90edc9ded2166ac422edcc10a6a0dc24e30f62 100644 --- a/tests/components/vera/test_switch.py +++ b/tests/components/vera/test_switch.py @@ -15,6 +15,7 @@ async def test_switch( vera_device = MagicMock(spec=pv.VeraSwitch) # type: pv.VeraSwitch vera_device.device_id = 1 vera_device.vera_device_id = vera_device.device_id + vera_device.comm_failure = False vera_device.name = "dev1" vera_device.category = pv.CATEGORY_SWITCH vera_device.is_switched_on = MagicMock(return_value=False)