Use enums in wallbox (#61997)

This commit is contained in:
Robert Hillis 2021-12-17 06:46:21 -05:00 committed by GitHub
parent 6b9447e3a2
commit 1c15e36afc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,17 +6,13 @@ import logging
from typing import cast
from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_POWER,
ELECTRIC_CURRENT_AMPERE,
ENERGY_KILO_WATT_HOUR,
LENGTH_KILOMETERS,
@ -63,23 +59,23 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = {
name="Charging Power",
precision=2,
native_unit_of_measurement=POWER_KILO_WATT,
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
device_class=SensorDeviceClass.POWER,
state_class=SensorStateClass.MEASUREMENT,
),
CONF_MAX_AVAILABLE_POWER_KEY: WallboxSensorEntityDescription(
key=CONF_MAX_AVAILABLE_POWER_KEY,
name="Max Available Power",
precision=0,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT,
state_class=STATE_CLASS_MEASUREMENT,
device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT,
),
CONF_CHARGING_SPEED_KEY: WallboxSensorEntityDescription(
key=CONF_CHARGING_SPEED_KEY,
icon="mdi:speedometer",
name="Charging Speed",
precision=0,
state_class=STATE_CLASS_MEASUREMENT,
state_class=SensorStateClass.MEASUREMENT,
),
CONF_ADDED_RANGE_KEY: WallboxSensorEntityDescription(
key=CONF_ADDED_RANGE_KEY,
@ -87,28 +83,28 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = {
name="Added Range",
precision=0,
native_unit_of_measurement=LENGTH_KILOMETERS,
state_class=STATE_CLASS_TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL_INCREASING,
),
CONF_ADDED_ENERGY_KEY: WallboxSensorEntityDescription(
key=CONF_ADDED_ENERGY_KEY,
name="Added Energy",
precision=2,
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
state_class=STATE_CLASS_TOTAL_INCREASING,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL_INCREASING,
),
CONF_COST_KEY: WallboxSensorEntityDescription(
key=CONF_COST_KEY,
icon="mdi:ev-station",
name="Cost",
state_class=STATE_CLASS_TOTAL_INCREASING,
state_class=SensorStateClass.TOTAL_INCREASING,
),
CONF_STATE_OF_CHARGE_KEY: WallboxSensorEntityDescription(
key=CONF_STATE_OF_CHARGE_KEY,
name="State of Charge",
native_unit_of_measurement=PERCENTAGE,
device_class=DEVICE_CLASS_BATTERY,
state_class=STATE_CLASS_MEASUREMENT,
device_class=SensorDeviceClass.BATTERY,
state_class=SensorStateClass.MEASUREMENT,
),
CONF_CURRENT_MODE_KEY: WallboxSensorEntityDescription(
key=CONF_CURRENT_MODE_KEY,
@ -130,8 +126,8 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = {
key=CONF_MAX_CHARGING_CURRENT_KEY,
name="Max. Charging Current",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT,
state_class=STATE_CLASS_MEASUREMENT,
device_class=SensorDeviceClass.CURRENT,
state_class=SensorStateClass.MEASUREMENT,
),
}