Use new enums in keba (#61869)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-15 12:06:47 +01:00 committed by GitHub
parent bc61c5f49e
commit 19f398259d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 22 deletions

View file

@ -1,9 +1,6 @@
"""Support for KEBA charging station binary sensors."""
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_CONNECTIVITY,
DEVICE_CLASS_PLUG,
DEVICE_CLASS_POWER,
DEVICE_CLASS_SAFETY,
BinarySensorDeviceClass,
BinarySensorEntity,
)
@ -19,14 +16,32 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
sensors = [
KebaBinarySensor(
keba, "Online", "Status", "device_state", DEVICE_CLASS_CONNECTIVITY
),
KebaBinarySensor(keba, "Plug", "Plug", "plug_state", DEVICE_CLASS_PLUG),
KebaBinarySensor(
keba, "State", "Charging State", "charging_state", DEVICE_CLASS_POWER
keba,
"Online",
"Status",
"device_state",
BinarySensorDeviceClass.CONNECTIVITY,
),
KebaBinarySensor(
keba, "Tmo FS", "Failsafe Mode", "failsafe_mode_state", DEVICE_CLASS_SAFETY
keba,
"Plug",
"Plug",
"plug_state",
BinarySensorDeviceClass.PLUG,
),
KebaBinarySensor(
keba,
"State",
"Charging State",
"charging_state",
BinarySensorDeviceClass.POWER,
),
KebaBinarySensor(
keba,
"Tmo FS",
"Failsafe Mode",
"failsafe_mode_state",
BinarySensorDeviceClass.SAFETY,
),
]
async_add_entities(sensors)

View file

@ -2,13 +2,10 @@
from __future__ import annotations
from homeassistant.components.sensor import (
DEVICE_CLASS_CURRENT,
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_POWER,
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE,
@ -34,7 +31,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
key="Curr user",
name="Max Current",
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT,
device_class=SensorDeviceClass.CURRENT,
),
),
KebaSensor(
@ -44,7 +41,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
key="Setenergy",
name="Energy Target",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
device_class=SensorDeviceClass.ENERGY,
),
),
KebaSensor(
@ -54,8 +51,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
key="P",
name="Charging Power",
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,
),
),
KebaSensor(
@ -65,7 +62,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
key="E pres",
name="Session Energy",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=DEVICE_CLASS_ENERGY,
device_class=SensorDeviceClass.ENERGY,
),
),
KebaSensor(
@ -75,8 +72,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
key="E total",
name="Total Energy",
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,
),
),
]