Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Commit

Permalink
Fix state refresh for light (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgarwood authored Jul 15, 2020
1 parent b59c3da commit 92d3249
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions custom_components/fullykiosk/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,19 @@ def device_info(self):
def unique_id(self):
return self._unique_id

def turn_on(self, **kwargs):
self.controller.screenOn()
async def async_turn_on(self, **kwargs):
await self.hass.async_add_executor_job(self.controller.screenOn)
brightness = kwargs.get(ATTR_BRIGHTNESS)
if brightness is None:
await self.coordinator.async_refresh()
return
if brightness != self.coordinator.data["screenBrightness"]:
self.controller.setScreenBrightness(brightness)
await self.coordinator.async_refresh()

def turn_off(self, **kwargs):
self.controller.screenOff()
async def async_turn_off(self, **kwargs):
await self.hass.async_add_executor_job(self.controller.screenOff)
await self.coordinator.async_refresh()

async def async_added_to_hass(self):
"""Connect to dispatcher listening for entity data notifications."""
Expand Down

0 comments on commit 92d3249

Please sign in to comment.