mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Update YouLess integration for long time measurements (#54767)
This commit is contained in:
parent
4a57392881
commit
90f7131328
@ -3,10 +3,22 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from youless_api.youless_sensor import YoulessSensor
|
from youless_api.youless_sensor import YoulessSensor
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import (
|
||||||
|
STATE_CLASS_MEASUREMENT,
|
||||||
|
STATE_CLASS_TOTAL_INCREASING,
|
||||||
|
SensorEntity,
|
||||||
|
)
|
||||||
from homeassistant.components.youless import DOMAIN
|
from homeassistant.components.youless import DOMAIN
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_DEVICE, DEVICE_CLASS_POWER
|
from homeassistant.const import (
|
||||||
|
CONF_DEVICE,
|
||||||
|
DEVICE_CLASS_ENERGY,
|
||||||
|
DEVICE_CLASS_GAS,
|
||||||
|
DEVICE_CLASS_POWER,
|
||||||
|
ENERGY_KILO_WATT_HOUR,
|
||||||
|
POWER_WATT,
|
||||||
|
VOLUME_CUBIC_METERS,
|
||||||
|
)
|
||||||
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.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
@ -95,6 +107,10 @@ class YoulessBaseSensor(CoordinatorEntity, SensorEntity):
|
|||||||
class GasSensor(YoulessBaseSensor):
|
class GasSensor(YoulessBaseSensor):
|
||||||
"""The Youless gas sensor."""
|
"""The Youless gas sensor."""
|
||||||
|
|
||||||
|
_attr_native_unit_of_measurement = VOLUME_CUBIC_METERS
|
||||||
|
_attr_device_class = DEVICE_CLASS_GAS
|
||||||
|
_attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
||||||
|
|
||||||
def __init__(self, coordinator: DataUpdateCoordinator, device: str) -> None:
|
def __init__(self, coordinator: DataUpdateCoordinator, device: str) -> None:
|
||||||
"""Instantiate a gas sensor."""
|
"""Instantiate a gas sensor."""
|
||||||
super().__init__(coordinator, device, "gas", "Gas meter", "gas")
|
super().__init__(coordinator, device, "gas", "Gas meter", "gas")
|
||||||
@ -110,7 +126,9 @@ class GasSensor(YoulessBaseSensor):
|
|||||||
class CurrentPowerSensor(YoulessBaseSensor):
|
class CurrentPowerSensor(YoulessBaseSensor):
|
||||||
"""The current power usage sensor."""
|
"""The current power usage sensor."""
|
||||||
|
|
||||||
|
_attr_native_unit_of_measurement = POWER_WATT
|
||||||
_attr_device_class = DEVICE_CLASS_POWER
|
_attr_device_class = DEVICE_CLASS_POWER
|
||||||
|
_attr_state_class = STATE_CLASS_MEASUREMENT
|
||||||
|
|
||||||
def __init__(self, coordinator: DataUpdateCoordinator, device: str) -> None:
|
def __init__(self, coordinator: DataUpdateCoordinator, device: str) -> None:
|
||||||
"""Instantiate the usage meter."""
|
"""Instantiate the usage meter."""
|
||||||
@ -127,7 +145,9 @@ class CurrentPowerSensor(YoulessBaseSensor):
|
|||||||
class DeliveryMeterSensor(YoulessBaseSensor):
|
class DeliveryMeterSensor(YoulessBaseSensor):
|
||||||
"""The Youless delivery meter value sensor."""
|
"""The Youless delivery meter value sensor."""
|
||||||
|
|
||||||
_attr_device_class = DEVICE_CLASS_POWER
|
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||||
|
_attr_device_class = DEVICE_CLASS_ENERGY
|
||||||
|
_attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, coordinator: DataUpdateCoordinator, device: str, dev_type: str
|
self, coordinator: DataUpdateCoordinator, device: str, dev_type: str
|
||||||
@ -151,7 +171,9 @@ class DeliveryMeterSensor(YoulessBaseSensor):
|
|||||||
class PowerMeterSensor(YoulessBaseSensor):
|
class PowerMeterSensor(YoulessBaseSensor):
|
||||||
"""The Youless low meter value sensor."""
|
"""The Youless low meter value sensor."""
|
||||||
|
|
||||||
_attr_device_class = DEVICE_CLASS_POWER
|
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||||
|
_attr_device_class = DEVICE_CLASS_ENERGY
|
||||||
|
_attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, coordinator: DataUpdateCoordinator, device: str, dev_type: str
|
self, coordinator: DataUpdateCoordinator, device: str, dev_type: str
|
||||||
@ -176,6 +198,7 @@ class PowerMeterSensor(YoulessBaseSensor):
|
|||||||
class ExtraMeterSensor(YoulessBaseSensor):
|
class ExtraMeterSensor(YoulessBaseSensor):
|
||||||
"""The Youless extra meter value sensor (s0)."""
|
"""The Youless extra meter value sensor (s0)."""
|
||||||
|
|
||||||
|
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||||
_attr_device_class = DEVICE_CLASS_POWER
|
_attr_device_class = DEVICE_CLASS_POWER
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user