Use DeviceClass and StateClass enums in broadlink (#61326)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-09 08:39:33 +01:00 committed by GitHub
parent 6d61a4678d
commit d7756efe55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 28 deletions

View file

@ -6,9 +6,8 @@ from broadlink.exceptions import BroadlinkException
import voluptuous as vol
from homeassistant.components.switch import (
DEVICE_CLASS_OUTLET,
DEVICE_CLASS_SWITCH,
PLATFORM_SCHEMA,
SwitchDeviceClass,
SwitchEntity,
)
from homeassistant.const import (
@ -136,7 +135,7 @@ class BroadlinkSwitch(BroadlinkEntity, SwitchEntity, RestoreEntity, ABC):
"""Representation of a Broadlink switch."""
_attr_assumed_state = True
_attr_device_class = DEVICE_CLASS_SWITCH
_attr_device_class = SwitchDeviceClass.SWITCH
def __init__(self, device, command_on, command_off):
"""Initialize the switch."""
@ -269,7 +268,7 @@ class BroadlinkBG1Slot(BroadlinkSwitch):
self._attr_is_on = self._coordinator.data[f"pwr{slot}"]
self._attr_name = f"{device.name} S{slot}"
self._attr_device_class = DEVICE_CLASS_OUTLET
self._attr_device_class = SwitchDeviceClass.OUTLET
self._attr_unique_id = f"{device.unique_id}-s{slot}"
def _update_state(self, data):