Use state class enum in Tibber (#60729)

This commit is contained in:
Daniel Hjelseth Høyer 2021-12-01 15:50:35 +01:00 committed by GitHub
parent 5d0cf4cb95
commit ecf1bc1b22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,12 +9,10 @@ from random import randrange
import aiohttp
from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL,
STATE_CLASS_TOTAL_INCREASING,
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
@ -55,14 +53,14 @@ RT_SENSORS: tuple[SensorEntityDescription, ...] = (
key="power",
name="power",
device_class=SensorDeviceClass.POWER,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=POWER_WATT,
),
SensorEntityDescription(
key="powerProduction",
name="power production",
device_class=SensorDeviceClass.POWER,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=POWER_WATT,
),
SensorEntityDescription(
@ -82,111 +80,111 @@ RT_SENSORS: tuple[SensorEntityDescription, ...] = (
name="accumulated consumption",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL,
state_class=SensorStateClass.TOTAL,
),
SensorEntityDescription(
key="accumulatedConsumptionLastHour",
name="accumulated consumption current hour",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="accumulatedProduction",
name="accumulated production",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL,
state_class=SensorStateClass.TOTAL,
),
SensorEntityDescription(
key="accumulatedProductionLastHour",
name="accumulated production current hour",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="lastMeterConsumption",
name="last meter consumption",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="lastMeterProduction",
name="last meter production",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL_INCREASING,
),
SensorEntityDescription(
key="voltagePhase1",
name="voltage phase1",
device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="voltagePhase2",
name="voltage phase2",
device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="voltagePhase3",
name="voltage phase3",
device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="currentL1",
name="current L1",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="currentL2",
name="current L2",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="currentL3",
name="current L3",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="signalStrength",
name="signal strength",
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),
SensorEntityDescription(
key="accumulatedReward",
name="accumulated reward",
device_class=SensorDeviceClass.MONETARY,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="accumulatedCost",
name="accumulated cost",
device_class=SensorDeviceClass.MONETARY,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
SensorEntityDescription(
key="powerFactor",
name="power factor",
device_class=SensorDeviceClass.POWER_FACTOR,
native_unit_of_measurement=PERCENTAGE,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
)