Skip to content

Commit

Permalink
Improve switch state after turn on/off
Browse files Browse the repository at this point in the history
  • Loading branch information
roleoroleo committed May 7, 2022
1 parent a6da985 commit 454f3aa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion custom_components/yi_hack/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def update(self):
(CONF_PASSWORD, self._password),
])
self._state = get_privacy(self.hass, self._device_name, conf)
set_privacy(self.hass, self._device_name, self._state)

def turn_off(self):
"""Turn off privacy (set camera on)."""
Expand All @@ -59,6 +58,7 @@ def turn_off(self):
set_power_on_in_progress(self.hass, self._device_name)
set_privacy(self.hass, self._device_name, False, conf)
self._state = False
self.schedule_update_ha_state(force_refresh=True)

def turn_on(self):
"""Turn on privacy (set camera off)."""
Expand All @@ -75,6 +75,7 @@ def turn_on(self):
set_power_off_in_progress(self.hass, self._device_name)
set_privacy(self.hass, self._device_name, True, conf)
self._state = True
self.schedule_update_ha_state(force_refresh=True)

@property
def is_on(self):
Expand Down

0 comments on commit 454f3aa

Please sign in to comment.