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.""" """Support for KEBA charging station binary sensors."""
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
DEVICE_CLASS_CONNECTIVITY, BinarySensorDeviceClass,
DEVICE_CLASS_PLUG,
DEVICE_CLASS_POWER,
DEVICE_CLASS_SAFETY,
BinarySensorEntity, BinarySensorEntity,
) )
@ -19,14 +16,32 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
sensors = [ sensors = [
KebaBinarySensor( KebaBinarySensor(
keba, "Online", "Status", "device_state", DEVICE_CLASS_CONNECTIVITY keba,
), "Online",
KebaBinarySensor(keba, "Plug", "Plug", "plug_state", DEVICE_CLASS_PLUG), "Status",
KebaBinarySensor( "device_state",
keba, "State", "Charging State", "charging_state", DEVICE_CLASS_POWER BinarySensorDeviceClass.CONNECTIVITY,
), ),
KebaBinarySensor( 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) async_add_entities(sensors)

View file

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