Add support for HSV encoded color lights (#90)

* Add support for HSV encoded color light

* Add debug logs for entity config

* Unset color when going to white mode
This commit is contained in:
Pierre Ståhl
2020-10-26 12:09:31 +01:00
committed by GitHub
parent f3cfde0308
commit d783293a21
4 changed files with 72 additions and 21 deletions

View File

@@ -219,6 +219,8 @@ class LocalTuyaEntity(Entity):
"""Subscribe localtuya events."""
await super().async_added_to_hass()
_LOGGER.debug("Adding %s with configuration: %s", self.entity_id, self._config)
def _update_handler(status):
"""Update entity state when status was updated."""
if status is not None:
@@ -291,7 +293,14 @@ class LocalTuyaEntity(Entity):
This method looks up which DP a certain config item uses based on
user configuration and returns its value.
"""
return self.dps(self._config.get(conf_item))
dp_index = self._config.get(conf_item)
if dp_index is None:
_LOGGER.warning(
"Entity %s is requesting unset index for option %s",
self.entity_id,
conf_item,
)
return self.dps(dp_index)
def status_updated(self):
"""Device status was updated.