Skip to content

Commit

Permalink
Try and fix blocking operation in event loop (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjw-s authored Jul 7, 2024
1 parent dbd5532 commit 43a865f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion custom_components/presence_simulation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ async def handle_presence_simulation(call, restart=False, switch_id=None):
await entity.set_start_datetime(datetime.now(hass.config.time_zone))
except Exception as e:
try:
await entity.set_start_datetime(datetime.now(pytz.timezone(hass.config.time_zone)))
presence_timezone = await hass.async_add_executor_job(pytz.timezone, hass.config.time_zone)
await entity.set_start_datetime(datetime.now(presence_timezone))
except Exception as e:
_LOGGER.warning("Start datetime could not be set to HA timezone: ", e)
await entity.set_start_datetime(datetime.now())
Expand Down

0 comments on commit 43a865f

Please sign in to comment.