Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix yeelight state update #22373

Merged
merged 1 commit into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions homeassistant/components/yeelight/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ def turn_on(self, duration=DEFAULT_TRANSITION):
_LOGGER.error("Unable to turn the bulb on: %s", ex)
return

self.update()

def turn_off(self, duration=DEFAULT_TRANSITION):
"""Turn off device."""
import yeelight
Expand All @@ -271,8 +269,6 @@ def turn_off(self, duration=DEFAULT_TRANSITION):
_LOGGER.error("Unable to turn the bulb on: %s", ex)
return

self.update()

def update(self):
"""Read new properties from the device."""
if not self.bulb:
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/yeelight/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ def turn_on(self, **kwargs) -> None:
except yeelight.BulbException as ex:
_LOGGER.error("Unable to set the defaults: %s", ex)
return
self.device.update()

def turn_off(self, **kwargs) -> None:
"""Turn off."""
Expand All @@ -502,18 +503,18 @@ def turn_off(self, **kwargs) -> None:
duration = int(kwargs.get(ATTR_TRANSITION) * 1000) # kwarg in s

self.device.turn_off(duration=duration)
self.device.update()

def set_mode(self, mode: str):
"""Set a power mode."""
import yeelight

try:
self._bulb.set_power_mode(yeelight.enums.PowerMode[mode.upper()])
self.device.update()
except yeelight.BulbException as ex:
_LOGGER.error("Unable to set the power mode: %s", ex)

self.device.update()

def start_flow(self, transitions, count=0, action=ACTION_RECOVER):
"""Start flow."""
import yeelight
Expand Down