mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 11:17:53 +00:00
Use ColorMode enum in bond (#70427)
This commit is contained in:
parent
7da2e765d1
commit
489e70bd7f
@ -8,12 +8,7 @@ from aiohttp.client_exceptions import ClientResponseError
|
|||||||
from bond_api import Action, BPUPSubscriptions, DeviceType
|
from bond_api import Action, BPUPSubscriptions, DeviceType
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
|
||||||
ATTR_BRIGHTNESS,
|
|
||||||
COLOR_MODE_BRIGHTNESS,
|
|
||||||
COLOR_MODE_ONOFF,
|
|
||||||
LightEntity,
|
|
||||||
)
|
|
||||||
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.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
@ -127,8 +122,8 @@ async def async_setup_entry(
|
|||||||
class BondBaseLight(BondEntity, LightEntity):
|
class BondBaseLight(BondEntity, LightEntity):
|
||||||
"""Representation of a Bond light."""
|
"""Representation of a Bond light."""
|
||||||
|
|
||||||
_attr_color_mode = COLOR_MODE_ONOFF
|
_attr_color_mode = ColorMode.ONOFF
|
||||||
_attr_supported_color_modes = {COLOR_MODE_ONOFF}
|
_attr_supported_color_modes = {ColorMode.ONOFF}
|
||||||
|
|
||||||
async def async_set_brightness_belief(self, brightness: int) -> None:
|
async def async_set_brightness_belief(self, brightness: int) -> None:
|
||||||
"""Set the belief state of the light."""
|
"""Set the belief state of the light."""
|
||||||
@ -172,8 +167,8 @@ class BondLight(BondBaseLight, BondEntity, LightEntity):
|
|||||||
"""Create HA entity representing Bond light."""
|
"""Create HA entity representing Bond light."""
|
||||||
super().__init__(hub, device, bpup_subs, sub_device)
|
super().__init__(hub, device, bpup_subs, sub_device)
|
||||||
if device.supports_set_brightness():
|
if device.supports_set_brightness():
|
||||||
self._attr_color_mode = COLOR_MODE_BRIGHTNESS
|
self._attr_color_mode = ColorMode.BRIGHTNESS
|
||||||
self._attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
|
self._attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||||
|
|
||||||
def _apply_state(self, state: dict) -> None:
|
def _apply_state(self, state: dict) -> None:
|
||||||
self._attr_is_on = state.get("light") == 1
|
self._attr_is_on = state.get("light") == 1
|
||||||
@ -270,8 +265,8 @@ class BondUpLight(BondBaseLight, BondEntity, LightEntity):
|
|||||||
class BondFireplace(BondEntity, LightEntity):
|
class BondFireplace(BondEntity, LightEntity):
|
||||||
"""Representation of a Bond-controlled fireplace."""
|
"""Representation of a Bond-controlled fireplace."""
|
||||||
|
|
||||||
_attr_color_mode = COLOR_MODE_BRIGHTNESS
|
_attr_color_mode = ColorMode.BRIGHTNESS
|
||||||
_attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
|
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||||
|
|
||||||
def _apply_state(self, state: dict) -> None:
|
def _apply_state(self, state: dict) -> None:
|
||||||
power = state.get("power")
|
power = state.get("power")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user