Skip to content

Commit

Permalink
Merge pull request #63 from Olixandyr/master
Browse files Browse the repository at this point in the history
Update light.py
  • Loading branch information
ClusterM committed Jun 9, 2024
2 parents 32a1beb + c7bfc5d commit 00f4507
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom_components/skykettle/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ColorMode, LightEntity, LightEntityFeature)
from homeassistant.const import CONF_FRIENDLY_NAME, STATE_OFF
from homeassistant.helpers.dispatcher import (async_dispatcher_connect,
async_dispatcher_send)
dispatcher_send)
from homeassistant.helpers.entity import EntityCategory

from .const import *
Expand Down Expand Up @@ -54,7 +54,7 @@ def update(self):
if (self.kettle.target_mode == SkyKettle.MODE_GAME and
self.kettle.current_mode == SkyKettle.MODE_GAME):
if not self.on:
self.hass.async_create_task(self.async_turn_on())
self.hass.create_task(self.async_turn_on())
else:
self.on = False

Expand Down Expand Up @@ -183,12 +183,12 @@ async def async_turn_on(self, **kwargs):
await self.kettle.set_color(self.light_type, self.n, kwargs[ATTR_RGB_COLOR])
if ATTR_BRIGHTNESS in kwargs:
await self.kettle.set_brightness(self.light_type, kwargs[ATTR_BRIGHTNESS])
self.hass.async_add_executor_job(async_dispatcher_send, self.hass, DISPATCHER_UPDATE)
self.hass.async_add_executor_job(dispatcher_send, self.hass, DISPATCHER_UPDATE)

async def async_turn_off(self, **kwargs):
"""Turn the light off."""
_LOGGER.debug(f"Turn off ({self.light_type}): {kwargs}")
if self.light_type == LIGHT_GAME:
await self.kettle.set_target_mode(STATE_OFF)
self.on = False
self.hass.async_add_executor_job(async_dispatcher_send, self.hass, DISPATCHER_UPDATE)
self.hass.async_add_executor_job(dispatcher_send, self.hass, DISPATCHER_UPDATE)

0 comments on commit 00f4507

Please sign in to comment.