Use ColorMode enum in bond (#70427)

This commit is contained in:
epenet 2022-04-23 02:44:31 +02:00 committed by GitHub
parent 7da2e765d1
commit 489e70bd7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,12 +8,7 @@ from aiohttp.client_exceptions import ClientResponseError
from bond_api import Action, BPUPSubscriptions, DeviceType
import voluptuous as vol
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
COLOR_MODE_BRIGHTNESS,
COLOR_MODE_ONOFF,
LightEntity,
)
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
@ -127,8 +122,8 @@ async def async_setup_entry(
class BondBaseLight(BondEntity, LightEntity):
"""Representation of a Bond light."""
_attr_color_mode = COLOR_MODE_ONOFF
_attr_supported_color_modes = {COLOR_MODE_ONOFF}
_attr_color_mode = ColorMode.ONOFF
_attr_supported_color_modes = {ColorMode.ONOFF}
async def async_set_brightness_belief(self, brightness: int) -> None:
"""Set the belief state of the light."""
@ -172,8 +167,8 @@ class BondLight(BondBaseLight, BondEntity, LightEntity):
"""Create HA entity representing Bond light."""
super().__init__(hub, device, bpup_subs, sub_device)
if device.supports_set_brightness():
self._attr_color_mode = COLOR_MODE_BRIGHTNESS
self._attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
self._attr_color_mode = ColorMode.BRIGHTNESS
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS}
def _apply_state(self, state: dict) -> None:
self._attr_is_on = state.get("light") == 1
@ -270,8 +265,8 @@ class BondUpLight(BondBaseLight, BondEntity, LightEntity):
class BondFireplace(BondEntity, LightEntity):
"""Representation of a Bond-controlled fireplace."""
_attr_color_mode = COLOR_MODE_BRIGHTNESS
_attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
_attr_color_mode = ColorMode.BRIGHTNESS
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
def _apply_state(self, state: dict) -> None:
power = state.get("power")