Use UnitOfVolumeFlowRate in huisbaasje and plugwise (#88967)
This commit is contained in:
parent
0c66346fb0
commit
23cdafd12f
4 changed files with 12 additions and 11 deletions
|
@ -8,14 +8,10 @@ from energyflip.const import (
|
||||||
SOURCE_TYPE_GAS,
|
SOURCE_TYPE_GAS,
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.const import UnitOfTime, UnitOfVolume
|
|
||||||
|
|
||||||
DATA_COORDINATOR = "coordinator"
|
DATA_COORDINATOR = "coordinator"
|
||||||
|
|
||||||
DOMAIN = "huisbaasje"
|
DOMAIN = "huisbaasje"
|
||||||
|
|
||||||
FLOW_CUBIC_METERS_PER_HOUR = f"{UnitOfVolume.CUBIC_METERS}/{UnitOfTime.HOURS}"
|
|
||||||
|
|
||||||
"""Interval in seconds between polls to huisbaasje."""
|
"""Interval in seconds between polls to huisbaasje."""
|
||||||
POLLING_INTERVAL = 20
|
POLLING_INTERVAL = 20
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,13 @@ from homeassistant.components.sensor import (
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
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.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.update_coordinator import (
|
from homeassistant.helpers.update_coordinator import (
|
||||||
|
@ -32,7 +38,6 @@ from homeassistant.helpers.update_coordinator import (
|
||||||
from .const import (
|
from .const import (
|
||||||
DATA_COORDINATOR,
|
DATA_COORDINATOR,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
FLOW_CUBIC_METERS_PER_HOUR,
|
|
||||||
SENSOR_TYPE_RATE,
|
SENSOR_TYPE_RATE,
|
||||||
SENSOR_TYPE_THIS_DAY,
|
SENSOR_TYPE_THIS_DAY,
|
||||||
SENSOR_TYPE_THIS_MONTH,
|
SENSOR_TYPE_THIS_MONTH,
|
||||||
|
@ -179,7 +184,7 @@ SENSORS_INFO = [
|
||||||
),
|
),
|
||||||
HuisbaasjeSensorEntityDescription(
|
HuisbaasjeSensorEntityDescription(
|
||||||
name="Huisbaasje Current Gas",
|
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,
|
sensor_type=SENSOR_TYPE_RATE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
key=SOURCE_TYPE_GAS,
|
key=SOURCE_TYPE_GAS,
|
||||||
|
|
|
@ -17,8 +17,8 @@ from homeassistant.const import (
|
||||||
UnitOfPower,
|
UnitOfPower,
|
||||||
UnitOfPressure,
|
UnitOfPressure,
|
||||||
UnitOfTemperature,
|
UnitOfTemperature,
|
||||||
UnitOfTime,
|
|
||||||
UnitOfVolume,
|
UnitOfVolume,
|
||||||
|
UnitOfVolumeFlowRate,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
@ -305,7 +305,7 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
|
||||||
key="gas_consumed_interval",
|
key="gas_consumed_interval",
|
||||||
name="Gas consumed interval",
|
name="Gas consumed interval",
|
||||||
icon="mdi:meter-gas",
|
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,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from homeassistant.components import huisbaasje
|
from homeassistant.components import huisbaasje
|
||||||
from homeassistant.components.huisbaasje.const import FLOW_CUBIC_METERS_PER_HOUR
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
ATTR_STATE_CLASS,
|
ATTR_STATE_CLASS,
|
||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
|
@ -18,6 +17,7 @@ from homeassistant.const import (
|
||||||
UnitOfEnergy,
|
UnitOfEnergy,
|
||||||
UnitOfPower,
|
UnitOfPower,
|
||||||
UnitOfVolume,
|
UnitOfVolume,
|
||||||
|
UnitOfVolumeFlowRate,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ async def test_setup_entry(hass: HomeAssistant) -> None:
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
current_gas.attributes.get(ATTR_UNIT_OF_MEASUREMENT)
|
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")
|
gas_today = hass.states.get("sensor.huisbaasje_gas_today")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue