Use device class enum in Tibber (#60705)

This commit is contained in:
Daniel Hjelseth Høyer 2021-12-01 11:00:17 +01:00 committed by GitHub
parent 3e9c72df5c
commit bcb2fefbe5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,16 +9,10 @@ from random import randrange
import aiohttp
from homeassistant.components.sensor import (
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_MONETARY,
DEVICE_CLASS_POWER,
DEVICE_CLASS_POWER_FACTOR,
DEVICE_CLASS_SIGNAL_STRENGTH,
DEVICE_CLASS_VOLTAGE,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL,
STATE_CLASS_TOTAL_INCREASING,
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
)
@ -54,123 +48,123 @@ RT_SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="averagePower",
name="average power",
device_class=DEVICE_CLASS_POWER,
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT,
),
SensorEntityDescription(
key="power",
name="power",
device_class=DEVICE_CLASS_POWER,
device_class=SensorDeviceClass.POWER,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=POWER_WATT,
),
SensorEntityDescription(
key="powerProduction",
name="power production",
device_class=DEVICE_CLASS_POWER,
device_class=SensorDeviceClass.POWER,
state_class=STATE_CLASS_MEASUREMENT,
native_unit_of_measurement=POWER_WATT,
),
SensorEntityDescription(
key="minPower",
name="min power",
device_class=DEVICE_CLASS_POWER,
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT,
),
SensorEntityDescription(
key="maxPower",
name="max power",
device_class=DEVICE_CLASS_POWER,
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT,
),
SensorEntityDescription(
key="accumulatedConsumption",
name="accumulated consumption",
device_class=DEVICE_CLASS_ENERGY,
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL,
),
SensorEntityDescription(
key="accumulatedConsumptionLastHour",
name="accumulated consumption current hour",
device_class=DEVICE_CLASS_ENERGY,
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
SensorEntityDescription(
key="accumulatedProduction",
name="accumulated production",
device_class=DEVICE_CLASS_ENERGY,
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL,
),
SensorEntityDescription(
key="accumulatedProductionLastHour",
name="accumulated production current hour",
device_class=DEVICE_CLASS_ENERGY,
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
SensorEntityDescription(
key="lastMeterConsumption",
name="last meter consumption",
device_class=DEVICE_CLASS_ENERGY,
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
SensorEntityDescription(
key="lastMeterProduction",
name="last meter production",
device_class=DEVICE_CLASS_ENERGY,
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
state_class=STATE_CLASS_TOTAL_INCREASING,
),
SensorEntityDescription(
key="voltagePhase1",
name="voltage phase1",
device_class=DEVICE_CLASS_VOLTAGE,
device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key="voltagePhase2",
name="voltage phase2",
device_class=DEVICE_CLASS_VOLTAGE,
device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key="voltagePhase3",
name="voltage phase3",
device_class=DEVICE_CLASS_VOLTAGE,
device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key="currentL1",
name="current L1",
device_class=DEVICE_CLASS_CURRENT,
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key="currentL2",
name="current L2",
device_class=DEVICE_CLASS_CURRENT,
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key="currentL3",
name="current L3",
device_class=DEVICE_CLASS_CURRENT,
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key="signalStrength",
name="signal strength",
device_class=DEVICE_CLASS_SIGNAL_STRENGTH,
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
state_class=STATE_CLASS_MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
@ -178,19 +172,19 @@ RT_SENSORS: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="accumulatedReward",
name="accumulated reward",
device_class=DEVICE_CLASS_MONETARY,
device_class=SensorDeviceClass.MONETARY,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key="accumulatedCost",
name="accumulated cost",
device_class=DEVICE_CLASS_MONETARY,
device_class=SensorDeviceClass.MONETARY,
state_class=STATE_CLASS_MEASUREMENT,
),
SensorEntityDescription(
key="powerFactor",
name="power factor",
device_class=DEVICE_CLASS_POWER_FACTOR,
device_class=SensorDeviceClass.POWER_FACTOR,
native_unit_of_measurement=PERCENTAGE,
state_class=STATE_CLASS_MEASUREMENT,
),