diff --git a/custom_components/mikrotik_router/binary_sensor.py b/custom_components/mikrotik_router/binary_sensor.py index 18562b3..7250f7a 100644 --- a/custom_components/mikrotik_router/binary_sensor.py +++ b/custom_components/mikrotik_router/binary_sensor.py @@ -112,9 +112,9 @@ class MikrotikControllerBinarySensor(BinarySensorDevice): return "{}-{}".format(self._inst.lower(), self._sensor.lower()) @property - def available(self): - """Return True if entity is available.""" - return bool(self._ctrl.data) + def available(self) -> bool: + """Return if controller is available.""" + return self._ctrl.connected() @property def device_info(self): diff --git a/custom_components/mikrotik_router/device_tracker.py b/custom_components/mikrotik_router/device_tracker.py index 8bb0bc7..c73486d 100644 --- a/custom_components/mikrotik_router/device_tracker.py +++ b/custom_components/mikrotik_router/device_tracker.py @@ -145,7 +145,7 @@ class MikrotikControllerPortDeviceTracker(ScannerEntity): return "{}-{}".format(self._inst.lower(), self._data['port-mac-address']) @property - def available(self): + def available(self) -> bool: """Return if controller is available.""" return self._ctrl.connected() diff --git a/custom_components/mikrotik_router/sensor.py b/custom_components/mikrotik_router/sensor.py index b787d0d..665f053 100644 --- a/custom_components/mikrotik_router/sensor.py +++ b/custom_components/mikrotik_router/sensor.py @@ -199,9 +199,9 @@ class MikrotikControllerSensor(Entity): return self._type[ATTR_UNIT] @property - def available(self): - """Return True if entity is available.""" - return bool(self._ctrl.data) + def available(self) -> bool: + """Return if controller is available.""" + return self._ctrl.connected() @property def device_info(self):