Use new enums in switcher_kis (#62400)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/62393/head^2
epenet 2021-12-20 16:53:40 +01:00 committed by GitHub
parent e5cf9b78bd
commit 75000c317b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 14 deletions

View File

@ -6,10 +6,9 @@ from dataclasses import dataclass
from aioswitcher.device import DeviceCategory from aioswitcher.device import DeviceCategory
from homeassistant.components.sensor import ( from homeassistant.components.sensor import (
DEVICE_CLASS_CURRENT, SensorDeviceClass,
DEVICE_CLASS_POWER,
STATE_CLASS_MEASUREMENT,
SensorEntity, SensorEntity,
SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ELECTRIC_CURRENT_AMPERE, POWER_WATT from homeassistant.const import ELECTRIC_CURRENT_AMPERE, POWER_WATT
@ -40,14 +39,14 @@ POWER_SENSORS = {
"power_consumption": AttributeDescription( "power_consumption": AttributeDescription(
name="Power Consumption", name="Power Consumption",
unit=POWER_WATT, unit=POWER_WATT,
device_class=DEVICE_CLASS_POWER, device_class=SensorDeviceClass.POWER,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
"electric_current": AttributeDescription( "electric_current": AttributeDescription(
name="Electric Current", name="Electric Current",
unit=ELECTRIC_CURRENT_AMPERE, unit=ELECTRIC_CURRENT_AMPERE,
device_class=DEVICE_CLASS_CURRENT, device_class=SensorDeviceClass.CURRENT,
state_class=STATE_CLASS_MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
} }

View File

@ -10,11 +10,7 @@ from aioswitcher.api import Command, SwitcherApi, SwitcherBaseResponse
from aioswitcher.device import DeviceCategory, DeviceState from aioswitcher.device import DeviceCategory, DeviceState
import voluptuous as vol import voluptuous as vol
from homeassistant.components.switch import ( from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity
DEVICE_CLASS_OUTLET,
DEVICE_CLASS_SWITCH,
SwitchEntity,
)
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import ( from homeassistant.helpers import (
@ -169,13 +165,13 @@ class SwitcherBaseSwitchEntity(CoordinatorEntity, SwitchEntity):
class SwitcherPowerPlugSwitchEntity(SwitcherBaseSwitchEntity): class SwitcherPowerPlugSwitchEntity(SwitcherBaseSwitchEntity):
"""Representation of a Switcher power plug switch entity.""" """Representation of a Switcher power plug switch entity."""
_attr_device_class = DEVICE_CLASS_OUTLET _attr_device_class = SwitchDeviceClass.OUTLET
class SwitcherWaterHeaterSwitchEntity(SwitcherBaseSwitchEntity): class SwitcherWaterHeaterSwitchEntity(SwitcherBaseSwitchEntity):
"""Representation of a Switcher water heater switch entity.""" """Representation of a Switcher water heater switch entity."""
_attr_device_class = DEVICE_CLASS_SWITCH _attr_device_class = SwitchDeviceClass.SWITCH
async def async_set_auto_off_service(self, auto_off: timedelta) -> None: async def async_set_auto_off_service(self, auto_off: timedelta) -> None:
"""Use for handling setting device auto-off service calls.""" """Use for handling setting device auto-off service calls."""