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

[bug] pyatv.exceptions.BlockedStateError: remote_control is blocked #300

Open
1 task done
kennymc-c opened this issue Jan 29, 2024 · 10 comments
Open
1 task done

[bug] pyatv.exceptions.BlockedStateError: remote_control is blocked #300

kennymc-c opened this issue Jan 29, 2024 · 10 comments
Assignees
Labels
bug Something isn't working integration Integration driver related issue

Comments

@kennymc-c
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Description

I recently added my Apple TV to Home Assistant. As a result, operation via Remote Two no longer worked. The log showed the following message:

2024-01-29 17:19:27.183139 +00:00	intg-appletv	INFO	pyatv.exceptions.BlockedStateError: remote_control is blocked
2024-01-29 17:19:27.183139 +00:00	intg-appletv	INFO	  File "pyatv/support/shield.py", line 71, in _guard_method
2024-01-29 17:19:27.183139 +00:00	intg-appletv	INFO	  File "tv.py", line 441, in cursorLeft
2024-01-29 17:19:27.183139 +00:00	intg-appletv	INFO	  File "driver.py", line 369, in event_handler
2024-01-29 17:19:27.183139 +00:00	intg-appletv	INFO	  File "pyee/base.py", line 139, in _emit_handle_potential_error
2024-01-29 17:19:27.183139 +00:00	intg-appletv	INFO	  File "pyee/base.py", line 179, in emit
2024-01-29 17:19:27.183139 +00:00	intg-appletv	INFO	  File "pyee/asyncio.py", line 71, in callback
2024-01-29 17:19:27.183139 +00:00	intg-appletv	INFO	  File "asyncio/events.py", line 81, in _run
2024-01-29 17:19:27.183139 +00:00	intg-appletv	INFO	Traceback (most recent call last):
2024-01-29 17:19:27.183139 +00:00	intg-appletv	INFO	handle: <Handle AsyncIOEventEmitter._emit_run.<locals>.callback(<Task finishe... is blocked')>) at pyee/asyncio.py:65>
2024-01-29 17:19:27.183139 +00:00	intg-appletv	INFO	ERROR:asyncio:Exception in callback AsyncIOEventEmitter._emit_run.<locals>.callback(<Task finishe... is blocked')>) at pyee/asyncio.py:65
2024-01-29 17:19:27.177180 +00:00	intg-appletv	INFO	DEBUG:ucapi.api:<-: {"kind":"req","id":21,"msg":"entity_command","msg_data":{"cmd_id":"cursor_left","entity_id":"40FC6C78-E08D-4A6B-9CBC-37078152133E","entity_type":"media_player"}}

Only after I removed the ATV from HA again, removed all corresponding remote apps in the ATV settings, removed the entity in the integration menu and then restarted the setup I was able to operate the device via the remote again. Before that, I only got messages like service not available or a timeout.

How to Reproduce

  1. Add Apple TV to Remote Two
  2. Add the same Apple TV to Home Assistant
  3. Try to control the Apple TV via Remote Two

Expected behavior

The Apple TV can be fully controlled via Remote Two

System version

1.6.7

What part of the system affected by the problem?

Integration

Additional context

No response

@kennymc-c kennymc-c added the bug Something isn't working label Jan 29, 2024
@github-project-automation github-project-automation bot moved this to Reported in Bug reports Jan 29, 2024
@github-actions github-actions bot added the integration Integration driver related issue label Jan 29, 2024
@martonborzak
Copy link
Contributor

Might be related to #315

@martonborzak martonborzak self-assigned this Mar 2, 2024
@martonborzak martonborzak moved this from Reported to In Progress in Bug reports Mar 2, 2024
@kennymc-c
Copy link
Author

I found out that the problem can be reproduced very easily by restarting the Apple TV. Beforehand, everything still works and after the restart, these error messages appear with every Apple TV command, which then result in a command timeout a short time later. Restarting the Remote Two solves the problem.

@martonborzak
Copy link
Contributor

I found out that the problem can be reproduced very easily by restarting the Apple TV. Beforehand, everything still works and after the restart, these error messages appear with every Apple TV command, which then result in a command timeout a short time later. Restarting the Remote Two solves the problem.

Thanks. So both the remote and HA can control the Apple TV before a restart?

@kennymc-c
Copy link
Author

I haven't used HA to control the Apple TV since I created this issue. Right now I only control it via the internal integration. I think HA could be unrelated to this issue. I can't remember exactly but maybe I also restarted the Apple TV when set up the integration in HA which caused the same issue.

@martonborzak
Copy link
Contributor

I haven't used HA to control the Apple TV since I created this issue. Right now I only control it via the internal integration. I think HA could be unrelated to this issue. I can't remember exactly but maybe I also restarted the Apple TV when set up the integration in HA which caused the same issue.

Just want to make sure because the original description says it only worked after removing from HA.

@zehnm zehnm moved this from In Progress to Done in Bug reports Mar 6, 2024
@zehnm
Copy link

zehnm commented Mar 6, 2024

Fixed in the next release.
I've found one cause for the BlockedStateError and also added a reconnect trigger in case it still occurs. This error is usually thrown if the connection has been dropped by the Apple TV, but the integration didn't create a new connection.

@zehnm
Copy link

zehnm commented Mar 7, 2024

New Apple TV integration is released in beta group. If we don't find a showstopper it will be released this week.

@kennymc-c
Copy link
Author

With 1.7.4 the BlockedStateError seems to be fixed but it still takes 5-10 seconds after a restart to control the Apple TV again. I noticed a KeyError in the integration logs:
UCR2_logs_2024-03-09.txt

@zehnm
Copy link

zehnm commented Mar 9, 2024

Restart of what, the ATV device or remote?

The error is a TimeoutError: ATV didn't respond

@kennymc-c
Copy link
Author

A restart of the Apple TV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working integration Integration driver related issue
Projects
Status: Done
Development

No branches or pull requests

3 participants