Use entity class vars in Flo (#50991)

This commit is contained in:
Franck Nijhof 2021-05-26 18:47:04 +02:00 committed by GitHub
parent daff62f42d
commit 67536b52c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 92 deletions

View file

@ -37,6 +37,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
class FloPendingAlertsBinarySensor(FloEntity, BinarySensorEntity):
"""Binary sensor that reports on if there are any pending system alerts."""
_attr_device_class = DEVICE_CLASS_PROBLEM
def __init__(self, device):
"""Initialize the pending alerts binary sensor."""
super().__init__("pending_system_alerts", "Pending System Alerts", device)
@ -57,15 +59,12 @@ class FloPendingAlertsBinarySensor(FloEntity, BinarySensorEntity):
"critical": self._device.pending_critical_alerts_count,
}
@property
def device_class(self):
"""Return the device class for the binary sensor."""
return DEVICE_CLASS_PROBLEM
class FloWaterDetectedBinarySensor(FloEntity, BinarySensorEntity):
"""Binary sensor that reports if water is detected (for leak detectors)."""
_attr_device_class = DEVICE_CLASS_PROBLEM
def __init__(self, device):
"""Initialize the pending alerts binary sensor."""
super().__init__("water_detected", "Water Detected", device)
@ -74,8 +73,3 @@ class FloWaterDetectedBinarySensor(FloEntity, BinarySensorEntity):
def is_on(self):
"""Return true if the Flo device is detecting water."""
return self._device.water_detected
@property
def device_class(self):
"""Return the device class for the binary sensor."""
return DEVICE_CLASS_PROBLEM