Set nest entities as unavailable on lost connection (#78773)
* NEST - Issues with lost internet connectivity #70479 Update Climate and Sensor entities to be unavailable when the device connectivity trait indicates the device is offline. The prior behavior, the last known values would be displayed indefinitely if the device lost internet connectivity. This was creating the illusion that the device was still connected. With this change, the Home Assistant entities will become unavailable when the device loses connectivity. * Update formatting * Add doc strings, fix indentation * Fix doc strings * Update test_climate_sdm.py * Update test_climate_sdm.py * Update test_sensor_sdm.py * Update test_sensor_sdm.py * more formatting fixes * Place availability logic in mixin 1. Consolidate repeated code into mixin and apply mixin to Climate and Sensor entities 2. Return true instead of super.available() 3. No unit test changes required to maintain code coverage * Define self._device is mixin to make linter happier * Remove logger used for debugging * restore whitespace * Fix test due to underlying merge change * Update availability_mixin.py * Move availability logic into device_info * Update sensor_sdm.py
This commit is contained in:
parent
1a9bcafbd2
commit
504ce8e93a
6 changed files with 141 additions and 3 deletions
|
@ -62,6 +62,11 @@ class SensorBase(SensorEntity):
|
|||
self._attr_unique_id = f"{device.name}-{self.device_class}"
|
||||
self._attr_device_info = self._device_info.device_info
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return the device availability."""
|
||||
return self._device_info.available
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Run when entity is added to register update signal handler."""
|
||||
self.async_on_remove(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue