diff --git a/homeassistant/components/streamlabswater/sensor.py b/homeassistant/components/streamlabswater/sensor.py index 1a1070d1ea8..42cf2bb588f 100644 --- a/homeassistant/components/streamlabswater/sensor.py +++ b/homeassistant/components/streamlabswater/sensor.py @@ -4,7 +4,7 @@ from __future__ import annotations from datetime import timedelta from homeassistant.components.sensor import SensorDeviceClass, SensorEntity -from homeassistant.const import VOLUME_GALLONS +from homeassistant.const import UnitOfVolume from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -80,7 +80,8 @@ class StreamlabsUsageData: class StreamLabsDailyUsage(SensorEntity): """Monitors the daily water usage.""" - _attr_device_class = SensorDeviceClass.VOLUME + _attr_device_class = SensorDeviceClass.WATER + _attr_native_unit_of_measurement = UnitOfVolume.GALLONS def __init__(self, location_name, streamlabs_usage_data): """Initialize the daily water usage device.""" @@ -89,25 +90,15 @@ class StreamLabsDailyUsage(SensorEntity): self._state = None @property - def name(self): + def name(self) -> str: """Return the name for daily usage.""" return f"{self._location_name} {NAME_DAILY_USAGE}" - @property - def icon(self): - """Return the daily usage icon.""" - return WATER_ICON - @property def native_value(self): """Return the current daily usage.""" return self._streamlabs_usage_data.get_daily_usage() - @property - def native_unit_of_measurement(self): - """Return gallons as the unit measurement for water.""" - return VOLUME_GALLONS - def update(self) -> None: """Retrieve the latest daily usage.""" self._streamlabs_usage_data.update() @@ -117,7 +108,7 @@ class StreamLabsMonthlyUsage(StreamLabsDailyUsage): """Monitors the monthly water usage.""" @property - def name(self): + def name(self) -> str: """Return the name for monthly usage.""" return f"{self._location_name} {NAME_MONTHLY_USAGE}" @@ -131,7 +122,7 @@ class StreamLabsYearlyUsage(StreamLabsDailyUsage): """Monitors the yearly water usage.""" @property - def name(self): + def name(self) -> str: """Return the name for yearly usage.""" return f"{self._location_name} {NAME_YEARLY_USAGE}"