1 """Support for Flo Water Monitor sensors."""
3 from __future__
import annotations
21 from .const
import DOMAIN
as FLO_DOMAIN
22 from .coordinator
import FloDeviceDataUpdateCoordinator
23 from .entity
import FloEntity
28 config_entry: ConfigEntry,
29 async_add_entities: AddEntitiesCallback,
31 """Set up the Flo sensors from config entry."""
32 devices: list[FloDeviceDataUpdateCoordinator] = hass.data[FLO_DOMAIN][
36 for device
in devices:
37 if device.device_type ==
"puck_oem":
59 """Monitors the daily water usage."""
61 _attr_native_unit_of_measurement = UnitOfVolume.GALLONS
62 _attr_state_class: SensorStateClass = SensorStateClass.TOTAL_INCREASING
63 _attr_device_class = SensorDeviceClass.WATER
64 _attr_translation_key =
"daily_consumption"
67 """Initialize the daily water usage sensor."""
68 super().
__init__(
"daily_consumption", device)
72 """Return the current daily usage."""
73 if self._device.consumption_today
is None:
75 return round(self._device.consumption_today, 1)
79 """Monitors the current Flo system mode."""
81 _attr_translation_key =
"current_system_mode"
84 """Initialize the system mode sensor."""
85 super().
__init__(
"current_system_mode", device)
89 """Return the current system mode."""
90 if not self._device.current_system_mode:
92 return self._device.current_system_mode
96 """Monitors the current water flow rate."""
98 _attr_native_unit_of_measurement = UnitOfVolumeFlowRate.GALLONS_PER_MINUTE
99 _attr_state_class: SensorStateClass = SensorStateClass.MEASUREMENT
100 _attr_device_class = SensorDeviceClass.VOLUME_FLOW_RATE
101 _attr_translation_key =
"current_flow_rate"
104 """Initialize the flow rate sensor."""
105 super().
__init__(
"current_flow_rate", device)
109 """Return the current flow rate."""
110 if self._device.current_flow_rate
is None:
112 return round(self._device.current_flow_rate, 1)
116 """Monitors the temperature."""
118 _attr_device_class = SensorDeviceClass.TEMPERATURE
119 _attr_native_unit_of_measurement = UnitOfTemperature.FAHRENHEIT
120 _attr_state_class: SensorStateClass = SensorStateClass.MEASUREMENT
123 """Initialize the temperature sensor."""
124 super().
__init__(
"temperature", device)
130 """Return the current temperature."""
131 if self._device.temperature
is None:
133 return round(self._device.temperature, 1)
137 """Monitors the humidity."""
139 _attr_device_class = SensorDeviceClass.HUMIDITY
140 _attr_native_unit_of_measurement = PERCENTAGE
141 _attr_state_class: SensorStateClass = SensorStateClass.MEASUREMENT
144 """Initialize the humidity sensor."""
145 super().
__init__(
"humidity", device)
149 """Return the current humidity."""
150 if self._device.humidity
is None:
152 return round(self._device.humidity, 1)
156 """Monitors the water pressure."""
158 _attr_device_class = SensorDeviceClass.PRESSURE
159 _attr_native_unit_of_measurement = UnitOfPressure.PSI
160 _attr_state_class: SensorStateClass = SensorStateClass.MEASUREMENT
161 _attr_translation_key =
"water_pressure"
164 """Initialize the pressure sensor."""
165 super().
__init__(
"water_pressure", device)
169 """Return the current water pressure."""
170 if self._device.current_psi
is None:
172 return round(self._device.current_psi, 1)
176 """Monitors the battery level for battery-powered leak detectors."""
178 _attr_device_class = SensorDeviceClass.BATTERY
179 _attr_native_unit_of_measurement = PERCENTAGE
180 _attr_state_class: SensorStateClass = SensorStateClass.MEASUREMENT
183 """Initialize the battery sensor."""
188 """Return the current battery level."""
189 return self._device.battery_level
def __init__(self, device)
float|None native_value(self)
def __init__(self, device)
float|None native_value(self)
float|None native_value(self)
def __init__(self, device)
def __init__(self, device)
float|None native_value(self)
float|None native_value(self)
def __init__(self, device)
def __init__(self, device)
str|None native_value(self)
float|None native_value(self)
def __init__(self, device, is_water)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)