Migrate scsgate light to ColorMode (#70904)

This commit is contained in:
epenet 2022-04-27 15:41:19 +02:00 committed by GitHub
parent abd60832fe
commit ea104feab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ import logging
from scsgate.tasks import ToggleStatusTask from scsgate.tasks import ToggleStatusTask
import voluptuous as vol import voluptuous as vol
from homeassistant.components.light import PLATFORM_SCHEMA, LightEntity from homeassistant.components.light import PLATFORM_SCHEMA, ColorMode, LightEntity
from homeassistant.const import ATTR_ENTITY_ID, ATTR_STATE, CONF_DEVICES, CONF_NAME from homeassistant.const import ATTR_ENTITY_ID, ATTR_STATE, CONF_DEVICES, CONF_NAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -54,9 +54,13 @@ def setup_platform(
class SCSGateLight(LightEntity): class SCSGateLight(LightEntity):
"""Representation of a SCSGate light.""" """Representation of a SCSGate light."""
_attr_color_mode = ColorMode.ONOFF
_attr_supported_color_modes = {ColorMode.ONOFF}
_attr_should_poll = False
def __init__(self, scs_id, name, logger, scsgate): def __init__(self, scs_id, name, logger, scsgate):
"""Initialize the light.""" """Initialize the light."""
self._name = name self._attr_name = name
self._scs_id = scs_id self._scs_id = scs_id
self._toggled = False self._toggled = False
self._logger = logger self._logger = logger
@ -67,16 +71,6 @@ class SCSGateLight(LightEntity):
"""Return the SCS ID.""" """Return the SCS ID."""
return self._scs_id return self._scs_id
@property
def should_poll(self):
"""No polling needed for a SCSGate light."""
return False
@property
def name(self):
"""Return the name of the device if any."""
return self._name
@property @property
def is_on(self): def is_on(self):
"""Return true if light is on.""" """Return true if light is on."""