Set water device class to flo, homewizard, p1_monitor, toon (#80944)

This commit is contained in:
Franck Nijhof 2022-10-25 13:21:47 +02:00 committed by GitHub
parent dbfca8def8
commit 5b32540a84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 3 deletions

View File

@ -71,6 +71,7 @@ class FloDailyUsageSensor(FloEntity, SensorEntity):
_attr_icon = WATER_ICON _attr_icon = WATER_ICON
_attr_native_unit_of_measurement = VOLUME_GALLONS _attr_native_unit_of_measurement = VOLUME_GALLONS
_attr_state_class: SensorStateClass = SensorStateClass.TOTAL_INCREASING _attr_state_class: SensorStateClass = SensorStateClass.TOTAL_INCREASING
_attr_device_class = SensorDeviceClass.WATER
def __init__(self, device): def __init__(self, device):
"""Initialize the daily water usage sensor.""" """Initialize the daily water usage sensor."""

View File

@ -131,7 +131,7 @@ SENSORS: Final[tuple[SensorEntityDescription, ...]] = (
name="Total water usage", name="Total water usage",
native_unit_of_measurement=VOLUME_CUBIC_METERS, native_unit_of_measurement=VOLUME_CUBIC_METERS,
icon="mdi:gauge", icon="mdi:gauge",
device_class=SensorDeviceClass.VOLUME, device_class=SensorDeviceClass.WATER,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
), ),
) )

View File

@ -222,13 +222,14 @@ SENSORS_WATERMETER: tuple[SensorEntityDescription, ...] = (
name="Consumption Day", name="Consumption Day",
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=VOLUME_LITERS, native_unit_of_measurement=VOLUME_LITERS,
device_class=SensorDeviceClass.VOLUME, device_class=SensorDeviceClass.WATER,
), ),
SensorEntityDescription( SensorEntityDescription(
key="consumption_total", key="consumption_total",
name="Consumption Total", name="Consumption Total",
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
native_unit_of_measurement=VOLUME_CUBIC_METERS, native_unit_of_measurement=VOLUME_CUBIC_METERS,
device_class=SensorDeviceClass.WATER,
), ),
SensorEntityDescription( SensorEntityDescription(
key="pulse_count", key="pulse_count",

View File

@ -316,6 +316,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
icon="mdi:water", icon="mdi:water",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
cls=ToonWaterMeterDeviceSensor, cls=ToonWaterMeterDeviceSensor,
device_class=SensorDeviceClass.WATER,
), ),
ToonSensorEntityDescription( ToonSensorEntityDescription(
key="water_daily_usage", key="water_daily_usage",
@ -326,6 +327,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
icon="mdi:water", icon="mdi:water",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
cls=ToonWaterMeterDeviceSensor, cls=ToonWaterMeterDeviceSensor,
device_class=SensorDeviceClass.WATER,
), ),
ToonSensorEntityDescription( ToonSensorEntityDescription(
key="water_meter_reading", key="water_meter_reading",
@ -337,6 +339,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
state_class=SensorStateClass.TOTAL_INCREASING, state_class=SensorStateClass.TOTAL_INCREASING,
cls=ToonWaterMeterDeviceSensor, cls=ToonWaterMeterDeviceSensor,
device_class=SensorDeviceClass.WATER,
), ),
ToonSensorEntityDescription( ToonSensorEntityDescription(
key="water_value", key="water_value",

View File

@ -609,7 +609,7 @@ async def test_sensor_entity_total_liters(
assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.TOTAL_INCREASING assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.TOTAL_INCREASING
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == VOLUME_CUBIC_METERS assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == VOLUME_CUBIC_METERS
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.VOLUME assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.WATER
assert state.attributes.get(ATTR_ICON) == "mdi:gauge" assert state.attributes.get(ATTR_ICON) == "mdi:gauge"