Decouple BroadlinkDevice.available property (#58853)

* Decouple BroadlinkDevice.available property

* Exclude unreachable line from coverage
This commit is contained in:
Felipe Martins Diel 2021-11-24 00:59:18 -03:00 committed by GitHub
parent be94ce42a5
commit 774e1b0022
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -56,6 +56,13 @@ class BroadlinkDevice:
"""Return the mac address of the device."""
return self.config.data[CONF_MAC]
@property
def available(self):
"""Return True if the device is available."""
if self.update_manager is None: # pragma: no cover
return False
return self.update_manager.available
@staticmethod
async def async_update(hass, entry):
"""Update the device and related entities.

View File

@ -47,8 +47,8 @@ class BroadlinkEntity(Entity):
@property
def available(self):
"""Return True if the remote is available."""
return self._device.update_manager.available
"""Return True if the entity is available."""
return self._device.available
@property
def device_info(self) -> DeviceInfo: