Skip to content

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
c503ghosh committed Jun 14, 2024
1 parent 53b3ca7 commit adede49
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/dirigera_platform/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ async def async_turn_on(self, **kwargs):
async def async_turn_off(self, **kwargs):
logger.debug("light turn_off...")
try:
self.reset_ignore_update()
await self.hass.async_add_executor_job(self._json_data.set_light,False)
self.async_schedule_update_ha_state(False)
except Exception as ex:
logger.error("error encountered turning off : {}".format(self.name))
logger.error(ex)
Expand Down Expand Up @@ -457,6 +459,7 @@ async def async_turn_on(self, **kwargs):
logger.debug(kwargs)

try:
self._controller.reset_ignore_update()
await self.hass.async_add_executor_job(self.patch_command,{"isOn": True})

if ATTR_BRIGHTNESS in kwargs:
Expand Down Expand Up @@ -488,6 +491,7 @@ async def async_turn_on(self, **kwargs):
self._color_hue = hs_tuple[0]
self._color_saturation = hs_tuple[1] / 100
# Saturation is 0 - 1 at IKEA
self._controller._ignore_update = True

await self.hass.async_add_executor_job(self.patch_command,{ "colorHue" : self._color_hue, "colorSaturation" : self._color_saturation})

Expand All @@ -497,11 +501,11 @@ async def async_turn_on(self, **kwargs):
raise HomeAssistantError(ex, DOMAIN, "hub_exception")

async def async_turn_off(self, **kwargs):
self._controller.reset_ignore_update()
logger.debug("light device_set turn_off...")
try:
await self.hass.async_add_executor_job(self.patch_command, {"isOn": False})
except Exception as ex:
logger.error("error encountered turning off device_set : {}".format(self.name))
logger.error(ex)
raise HomeAssistantError(ex, DOMAIN, "hub_exception")

raise HomeAssistantError(ex, DOMAIN, "hub_exception")

0 comments on commit adede49

Please sign in to comment.