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

Error calling next_media after core update 2024.5.0 #48

Closed
goodlucknow opened this issue May 1, 2024 · 6 comments · Fixed by #51
Closed

Error calling next_media after core update 2024.5.0 #48

goodlucknow opened this issue May 1, 2024 · 6 comments · Fixed by #51
Assignees
Labels
bug Something isn't working

Comments

@goodlucknow
Copy link

Version of the custom_component

v0.6.2

Describe the bug

Error thrown when calling next_media.

Debug log


2024-05-01 23:54:52.984 WARNING (SyncWorker_0) [homeassistant.helpers.frame] Detected that custom integration 'google_photos' calls async_create_task from a thread at custom_components/google_photos/camera.py, line 135: self.hass.async_add_job(self.coordinator.select_next(mode)), please report it to the author of the 'google_photos' custom integration
2024-05-01 23:54:52.986 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: Detected that custom integration 'google_photos' calls async_create_task from a thread at custom_components/google_photos/camera.py, line 135: self.hass.async_add_job(self.coordinator.select_next(mode)). Please report it to the author of the 'google_photos' custom integration.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 501, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 736, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 699, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2738, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1047, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  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/google_photos/camera.py", line 135, in next_media
    self.hass.async_add_job(self.coordinator.select_next(mode))
  File "/usr/src/homeassistant/homeassistant/core.py", line 645, in async_add_job
    return self.async_create_task(target, eager_start=eager_start)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 'google_photos' calls async_create_task from a thread at custom_components/google_photos/camera.py, line 135: self.hass.async_add_job(self.coordinator.select_next(mode)). Please report it to the author of the 'google_photos' custom integration.
2024-05-01 23:54:52.989 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [281472507413696] 
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 793, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1731, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 503, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 533, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 501, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 736, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 699, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2738, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2779, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1047, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  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/google_photos/camera.py", line 135, in next_media
    self.hass.async_add_job(self.coordinator.select_next(mode))
  File "/usr/src/homeassistant/homeassistant/core.py", line 645, in async_add_job
    return self.async_create_task(target, eager_start=eager_start)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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 'google_photos' calls async_create_task from a thread at custom_components/google_photos/camera.py, line 135: self.hass.async_add_job(self.coordinator.select_next(mode)). Please report it to the author of the 'google_photos' custom integration.

@goodlucknow
Copy link
Author

note that photos will still update if done automatically via update interval.
this occurs when calling next media service manually.

@goodlucknow
Copy link
Author

one workaround is a script that sets update interval to 10 seconds, waits 10 seconds, then sets update interval back to never, instead of calling next media service.
just in case anyone else is also having this issue.

@Daanoz Daanoz added the bug Something isn't working label May 4, 2024
@Daanoz Daanoz self-assigned this May 4, 2024
@MasterDimi
Copy link

Same here:
Failed to call service google_photos/next_media. Detected that custom integration 'google_photos' calls async_create_task from a thread at custom_components/google_photos/camera.py, line 135: self.hass.async_add_job(self.coordinator.select_next(mode)). Please report it to the author of the 'google_photos' custom integration.

For now i will use the workaround

@Daanoz Daanoz closed this as completed in #51 May 9, 2024
Daanoz added a commit that referenced this issue May 9, 2024
…-core-update-2024.5.0-48

fix: Error calling next_media after core update 2024.5.0 #48
@Daanoz
Copy link
Owner

Daanoz commented May 9, 2024

I have a pre-release version ready that should solve it: https://github.com/Daanoz/ha-google-photos/releases/tag/v0.6.3. If I don't see any issues the coming days I'll do a full release. Let me know if you encounter any issues.

@goodlucknow
Copy link
Author

Magic, thanks so much.
I'll try this out soon as I can.

@goodlucknow
Copy link
Author

Installed here and all working, no errors so far

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants