From 774e1b0022747972bce0dc98768603511bad8e20 Mon Sep 17 00:00:00 2001 From: Felipe Martins Diel <41558831+felipediel@users.noreply.github.com> Date: Wed, 24 Nov 2021 00:59:18 -0300 Subject: [PATCH] Decouple BroadlinkDevice.available property (#58853) * Decouple BroadlinkDevice.available property * Exclude unreachable line from coverage --- homeassistant/components/broadlink/device.py | 7 +++++++ homeassistant/components/broadlink/entity.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/broadlink/device.py b/homeassistant/components/broadlink/device.py index 1d1fe273252..951be9b26bb 100644 --- a/homeassistant/components/broadlink/device.py +++ b/homeassistant/components/broadlink/device.py @@ -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. diff --git a/homeassistant/components/broadlink/entity.py b/homeassistant/components/broadlink/entity.py index 25bfd87140b..2c7a05a7e70 100644 --- a/homeassistant/components/broadlink/entity.py +++ b/homeassistant/components/broadlink/entity.py @@ -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: