home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.3k stars 30.62k forks source link

Not able to excute cast service when called from internet request #86609

Closed kimvonmullen closed 1 year ago

kimvonmullen commented 1 year ago

The problem

I use flic buttons to make an internet request into HA, which then run scripts or other services. This setup works but now I have made a script that call the service cast to show a dashboard on a google hub. Ha gives an wrror and will however not allow the script to run when i used it with the button/internet request. It works if the script is called from HA, it also works with internet reuest for all other scripts that I have

I use post request to apiserives/script/turn_on

What version of Home Assistant Core has the issue?

2023.1.7

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

cast

Link to integration documentation on our website

https://www.home-assistant.io/integrations/cast/

Diagnostics information

No response

Example YAML snippet

sequence:
  - service: cast.show_lovelace_view
    data:
      entity_id: media_player.stue_hub
      dashboard_path: lovelace-cast
      view_path: dash-stue

Anything in the logs that might be useful for us?

2023-01-25 08:12:04.962 INFO (MainThread) [homeassistant.components.script.dashboard_stue] Dashboard stue: Running script sequence
2023-01-25 08:12:04.963 INFO (MainThread) [homeassistant.components.script.dashboard_stue] Dashboard stue: Executing step call service
2023-01-25 08:12:04.970 ERROR (MainThread) [homeassistant.components.script.dashboard_stue] Dashboard stue: Error executing script. Unauthorized for call_service at pos 1: Unauthorized
2023-01-25 08:12:04.975 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 462, in _async_run
    return await self.script.async_run(script_vars, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1755, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1792, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 747, in admin_handler
    raise Unauthorized(context=call.context)
homeassistant.exceptions.Unauthorized: Unauthorized

2023-01-25 08:12:38.791 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 462, in _async_run
    return await self.script.async_run(script_vars, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1755, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1792, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 747, in admin_handler
    raise Unauthorized(context=call.context)
homeassistant.exceptions.Unauthorized: Unauthorized

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @emontnemery, mind taking a look at this issue as it has been labeled with an integration (cast) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `cast` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign cast` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


cast documentation cast source (message by IssueLinks)

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.