Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	custom_components/duofern/services.yaml
  • Loading branch information
gluap committed Feb 8, 2023
2 parents a43c623 + e1b1072 commit bf57131
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions custom_components/duofern/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,20 @@ def update_callback(id, key, value):
try:
_LOGGER.info(f"scheduling update for {id}")
device = hass.data[DOMAIN]['devices'][id] # Get device by id
try:
device.schedule_update_ha_state(True) # Trigger update on the updated entity
except AssertionError:
_LOGGER.info("Update callback called before HA is ready") # Trying to update before HA is ready
if device.enabled:
try:
device.schedule_update_ha_state(True) # Trigger update on the updated entity
except AssertionError:
_LOGGER.info("Update callback called before HA is ready") # Trying to update before HA is ready
except KeyError:
_LOGGER.info("Update callback called on unknown device id") # Ignore invalid device ids

stick.add_updates_callback(update_callback)

time.sleep(5) # Wait for 5 seconds so HA can get our entities ready so we don't miss any updates (there are probably nicer ways to do this)
stick.start() # Start the stick after 5 seconds
def started_callback(event):
stick.start() # Start the stick when ha is ready

hass.bus.listen("homeassistant_started", started_callback)

return True

Expand Down
2 changes: 1 addition & 1 deletion custom_components/duofern/services.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Describes the format for available Wink services

start_pairing:
description: pair duofern devices
description: Pair duofern devices. Remember: There is no pairing UI. To pick up the newly paired devices later, you need to call sync_devices and possibly restart HA.
fields:
timeout:
description: timeout in seconds
Expand Down

0 comments on commit bf57131

Please sign in to comment.