slashback100 / presence_simulation

Home Assistant Presence Simulation
423 stars 22 forks source link

Presence Simulation fails to start in HA 2024.5.2 #132

Closed Dizzybacon closed 1 month ago

Dizzybacon commented 1 month ago

I was running HA 2024.1 and it worked fine, upgraded to 2024.5.2 and now Presence Simulation isn't working.

First noticed it when it should have been turned on by a script, in the traces the error is:

Error: Detected that custom integration 'presence_simulation' calls async_create_task from a thread at custom_components/presence_simulation/__init__.py, line 224: hass.async_create_task(simulate_single_entity(entity_id, dic[entity_id], overridden_delta, overridden_random)). Please report it to the author of the 'presence_simulation' custom integration.

Then when I go to the entity and turn it on it looks to have worked, but the logs say:

Logger: homeassistant.core
Source: core.py:2758
First occurred: 13:48:15 (1 occurrences)
Last logged: 13:48:15

Error executing service: <ServiceCall presence_simulation.start (c:01HXH5A66NTBAVY1V2PFG0ZNXG)>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 2758, in _run_service_call_catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/presence_simulation/__init__.py", line 216, in handle_presence_simulation
    await get_instance(hass).async_add_executor_job(handle_presence_simulation_sync, hass, call, minus_delta, expanded_entities, overridden_delta, overridden_random, entities_after_restart, delta_after_restart)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/presence_simulation/__init__.py", line 224, in handle_presence_simulation_sync
    hass.async_create_task(simulate_single_entity(entity_id, dic[entity_id], overridden_delta, overridden_random))
  File "/usr/src/homeassistant/homeassistant/core.py", line 816, in async_create_task
    self.verify_event_loop_thread("async_create_task")
  File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread
    frame.report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration
    raise RuntimeError(
RuntimeError: Detected that custom integration 'presence_simulation' calls async_create_task from a thread at custom_components/presence_simulation/__init__.py, line 224: hass.async_create_task(simulate_single_entity(entity_id, dic[entity_id], overridden_delta, overridden_random)). Please report it to the author of the 'presence_simulation' custom integration.
Dizzybacon commented 1 month ago

Updated to latest version and it works fine! Should have done that before opening the ticket.