Migrate bond light to color_mode (#69078)
This commit is contained in:
parent
aa969d5ae8
commit
66e9b263a8
2 changed files with 40 additions and 7 deletions
|
@ -10,7 +10,8 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
SUPPORT_BRIGHTNESS,
|
||||
COLOR_MODE_BRIGHTNESS,
|
||||
COLOR_MODE_ONOFF,
|
||||
LightEntity,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -126,7 +127,8 @@ async def async_setup_entry(
|
|||
class BondBaseLight(BondEntity, LightEntity):
|
||||
"""Representation of a Bond light."""
|
||||
|
||||
_attr_supported_features = 0
|
||||
_attr_color_mode = COLOR_MODE_ONOFF
|
||||
_attr_supported_color_modes = {COLOR_MODE_ONOFF}
|
||||
|
||||
async def async_set_brightness_belief(self, brightness: int) -> None:
|
||||
"""Set the belief state of the light."""
|
||||
|
@ -170,7 +172,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_supported_features = SUPPORT_BRIGHTNESS
|
||||
self._attr_color_mode = COLOR_MODE_BRIGHTNESS
|
||||
self._attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
|
||||
|
||||
def _apply_state(self, state: dict) -> None:
|
||||
self._attr_is_on = state.get("light") == 1
|
||||
|
@ -267,7 +270,8 @@ class BondUpLight(BondBaseLight, BondEntity, LightEntity):
|
|||
class BondFireplace(BondEntity, LightEntity):
|
||||
"""Representation of a Bond-controlled fireplace."""
|
||||
|
||||
_attr_supported_features = SUPPORT_BRIGHTNESS
|
||||
_attr_color_mode = COLOR_MODE_BRIGHTNESS
|
||||
_attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
|
||||
|
||||
def _apply_state(self, state: dict) -> None:
|
||||
power = state.get("power")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue