From 19f398259da741f6fadd88a7d0f4c71e6411f944 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 15 Dec 2021 12:06:47 +0100 Subject: [PATCH] Use new enums in keba (#61869) Co-authored-by: epenet --- .../components/keba/binary_sensor.py | 35 +++++++++++++------ homeassistant/components/keba/sensor.py | 21 +++++------ 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/homeassistant/components/keba/binary_sensor.py b/homeassistant/components/keba/binary_sensor.py index 29292470155..05659bd8336 100644 --- a/homeassistant/components/keba/binary_sensor.py +++ b/homeassistant/components/keba/binary_sensor.py @@ -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) diff --git a/homeassistant/components/keba/sensor.py b/homeassistant/components/keba/sensor.py index fc761074bc7..248e6544646 100644 --- a/homeassistant/components/keba/sensor.py +++ b/homeassistant/components/keba/sensor.py @@ -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, ), ), ]