Fix home connect lights setting color (#45470)

This commit is contained in:
Josias Montag 2021-01-27 11:02:32 +01:00 committed by GitHub
parent 459236fcdd
commit fb2db34334
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,6 +90,16 @@ class HomeConnectLight(HomeConnectEntity, LightEntity):
async def async_turn_on(self, **kwargs): async def async_turn_on(self, **kwargs):
"""Switch the light on, change brightness, change color.""" """Switch the light on, change brightness, change color."""
if self._ambient: if self._ambient:
_LOGGER.debug("Switching ambient light on for: %s", self.name)
try:
await self.hass.async_add_executor_job(
self.device.appliance.set_setting,
self._key,
True,
)
except HomeConnectError as err:
_LOGGER.error("Error while trying to turn on ambient light: %s", err)
return
if ATTR_BRIGHTNESS in kwargs or ATTR_HS_COLOR in kwargs: if ATTR_BRIGHTNESS in kwargs or ATTR_HS_COLOR in kwargs:
try: try:
await self.hass.async_add_executor_job( await self.hass.async_add_executor_job(
@ -119,18 +129,6 @@ class HomeConnectLight(HomeConnectEntity, LightEntity):
_LOGGER.error( _LOGGER.error(
"Error while trying setting the color: %s", err "Error while trying setting the color: %s", err
) )
else:
_LOGGER.debug("Switching ambient light on for: %s", self.name)
try:
await self.hass.async_add_executor_job(
self.device.appliance.set_setting,
self._key,
True,
)
except HomeConnectError as err:
_LOGGER.error(
"Error while trying to turn on ambient light: %s", err
)
elif ATTR_BRIGHTNESS in kwargs: elif ATTR_BRIGHTNESS in kwargs:
_LOGGER.debug("Changing brightness for: %s", self.name) _LOGGER.debug("Changing brightness for: %s", self.name)