Add support for Flo "pucks" (#47074)
So far the Flo integration only supports shutoff valves. Add support for Flo leak detector pucks, which measure temperature and humidity in addition to providing leak alerts.
This commit is contained in:
parent
d37fb7d88d
commit
ad86eb4be3
14 changed files with 389 additions and 66 deletions
|
@ -17,7 +17,21 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
devices: List[FloDeviceDataUpdateCoordinator] = hass.data[FLO_DOMAIN][
|
||||
config_entry.entry_id
|
||||
]["devices"]
|
||||
entities = [FloPendingAlertsBinarySensor(device) for device in devices]
|
||||
entities = []
|
||||
for device in devices:
|
||||
if device.device_type == "puck_oem":
|
||||
# Flo "pucks" (leak detectors) *do* support pending alerts.
|
||||
# However these pending alerts mix unrelated issues like
|
||||
# low-battery alerts, humidity alerts, & temperature alerts
|
||||
# in addition to the critical "water detected" alert.
|
||||
#
|
||||
# Since there are non-binary sensors for battery, humidity,
|
||||
# and temperature, the binary sensor should only cover
|
||||
# water detection. If this sensor trips, you really have
|
||||
# a problem - vs. battery/temp/humidity which are warnings.
|
||||
entities.append(FloWaterDetectedBinarySensor(device))
|
||||
else:
|
||||
entities.append(FloPendingAlertsBinarySensor(device))
|
||||
async_add_entities(entities)
|
||||
|
||||
|
||||
|
@ -48,3 +62,21 @@ class FloPendingAlertsBinarySensor(FloEntity, BinarySensorEntity):
|
|||
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)."""
|
||||
|
||||
def __init__(self, device):
|
||||
"""Initialize the pending alerts binary sensor."""
|
||||
super().__init__("water_detected", "Water Detected", device)
|
||||
|
||||
@property
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue