diff --git a/homeassistant/components/huisbaasje/const.py b/homeassistant/components/huisbaasje/const.py index 9931b33a996..f9084831263 100644 --- a/homeassistant/components/huisbaasje/const.py +++ b/homeassistant/components/huisbaasje/const.py @@ -8,14 +8,10 @@ from energyflip.const import ( SOURCE_TYPE_GAS, ) -from homeassistant.const import UnitOfTime, UnitOfVolume - DATA_COORDINATOR = "coordinator" DOMAIN = "huisbaasje" -FLOW_CUBIC_METERS_PER_HOUR = f"{UnitOfVolume.CUBIC_METERS}/{UnitOfTime.HOURS}" - """Interval in seconds between polls to huisbaasje.""" POLLING_INTERVAL = 20 diff --git a/homeassistant/components/huisbaasje/sensor.py b/homeassistant/components/huisbaasje/sensor.py index f73d4bf3129..369c6eba075 100644 --- a/homeassistant/components/huisbaasje/sensor.py +++ b/homeassistant/components/huisbaasje/sensor.py @@ -21,7 +21,13 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_ID, UnitOfEnergy, UnitOfPower, UnitOfVolume +from homeassistant.const import ( + CONF_ID, + UnitOfEnergy, + UnitOfPower, + UnitOfVolume, + UnitOfVolumeFlowRate, +) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import ( @@ -32,7 +38,6 @@ from homeassistant.helpers.update_coordinator import ( from .const import ( DATA_COORDINATOR, DOMAIN, - FLOW_CUBIC_METERS_PER_HOUR, SENSOR_TYPE_RATE, SENSOR_TYPE_THIS_DAY, SENSOR_TYPE_THIS_MONTH, @@ -179,7 +184,7 @@ SENSORS_INFO = [ ), HuisbaasjeSensorEntityDescription( name="Huisbaasje Current Gas", - native_unit_of_measurement=FLOW_CUBIC_METERS_PER_HOUR, + native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR, sensor_type=SENSOR_TYPE_RATE, state_class=SensorStateClass.MEASUREMENT, key=SOURCE_TYPE_GAS, diff --git a/homeassistant/components/plugwise/sensor.py b/homeassistant/components/plugwise/sensor.py index 354656ecd9e..d708fe741c2 100644 --- a/homeassistant/components/plugwise/sensor.py +++ b/homeassistant/components/plugwise/sensor.py @@ -17,8 +17,8 @@ from homeassistant.const import ( UnitOfPower, UnitOfPressure, UnitOfTemperature, - UnitOfTime, UnitOfVolume, + UnitOfVolumeFlowRate, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -305,7 +305,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = ( key="gas_consumed_interval", name="Gas consumed interval", icon="mdi:meter-gas", - native_unit_of_measurement=f"{UnitOfVolume.CUBIC_METERS}/{UnitOfTime.HOURS}", + native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( diff --git a/tests/components/huisbaasje/test_sensor.py b/tests/components/huisbaasje/test_sensor.py index 53734cde489..d3a65a0be6d 100644 --- a/tests/components/huisbaasje/test_sensor.py +++ b/tests/components/huisbaasje/test_sensor.py @@ -2,7 +2,6 @@ from unittest.mock import patch from homeassistant.components import huisbaasje -from homeassistant.components.huisbaasje.const import FLOW_CUBIC_METERS_PER_HOUR from homeassistant.components.sensor import ( ATTR_STATE_CLASS, SensorDeviceClass, @@ -18,6 +17,7 @@ from homeassistant.const import ( UnitOfEnergy, UnitOfPower, UnitOfVolume, + UnitOfVolumeFlowRate, ) from homeassistant.core import HomeAssistant @@ -292,7 +292,7 @@ async def test_setup_entry(hass: HomeAssistant) -> None: ) assert ( current_gas.attributes.get(ATTR_UNIT_OF_MEASUREMENT) - == FLOW_CUBIC_METERS_PER_HOUR + == UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR ) gas_today = hass.states.get("sensor.huisbaasje_gas_today")