Migrate firmata light to color_mode (#69256)

This commit is contained in:
Erik Montnemery 2022-04-04 18:17:21 +02:00 committed by GitHub
parent 67c95e92b1
commit 5d56f94786
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,7 @@ import logging
from homeassistant.components.light import ( from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_BRIGHTNESS,
SUPPORT_BRIGHTNESS, COLOR_MODE_BRIGHTNESS,
LightEntity, LightEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -56,6 +56,9 @@ async def async_setup_entry(
class FirmataLight(FirmataPinEntity, LightEntity): class FirmataLight(FirmataPinEntity, LightEntity):
"""Representation of a light on a Firmata board.""" """Representation of a light on a Firmata board."""
_attr_color_mode = COLOR_MODE_BRIGHTNESS
_attr_supported_color_modes = {COLOR_MODE_BRIGHTNESS}
def __init__( def __init__(
self, self,
api: FirmataBoardPin, api: FirmataBoardPin,
@ -83,11 +86,6 @@ class FirmataLight(FirmataPinEntity, LightEntity):
"""Return the brightness of the light.""" """Return the brightness of the light."""
return self._api.state return self._api.state
@property
def supported_features(self) -> int:
"""Flag supported features."""
return SUPPORT_BRIGHTNESS
async def async_turn_on(self, **kwargs) -> None: async def async_turn_on(self, **kwargs) -> None:
"""Turn on light.""" """Turn on light."""
level = kwargs.get(ATTR_BRIGHTNESS, self._last_on_level) level = kwargs.get(ATTR_BRIGHTNESS, self._last_on_level)