core icon indicating copy to clipboard operation
core copied to clipboard

MediaPlayer:Toggle does not turn Off Cast devices

Open mvdwetering opened this issue 3 years ago • 23 comments

The problem

When using the MediaPlayer:Toggle service with a Cast media_player it does turn On, but when calling MediaPlayer:Toggle again it does not turn Off

When watching with the developer tools I see the following:

  • Cast media_player has state Off, frontend shows player is Off (gray card, no title or play button)
  • Call MediaPlayer:Toggle on the Cast media_player
  • State changes to Idle, frontend shows media_player is active (colored card, additional controls like play button became visible)
  • Call MediaPlayer:Toggle on the Cast media_player
  • State stays Idle, no errors in the log, no change in frontend

What version of Home Assistant Core has the issue?

core-2022.8.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Cast

Link to integration documentation on our website

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

Diagnostics information

Does not support diagnostics it seems

Example YAML snippet

I am using the UI mode for calling the service, but this is what it shows when switching to YAML mode:

service: media_player.toggle
data: {}
target:
  entity_id:
    - media_player.googlehome7482

Anything in the logs that might be useful for us?

No errors

Additional information

No response

mvdwetering avatar Aug 27 '22 13:08 mvdwetering

cast documentation cast source (message by IssueLinks)

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! (message by CodeOwnersMention)

Turns out that the MediaPlayer async_toggle considers STATE_IDLE to be Off which is why it won't turn Off when it is Idle.

        if self.state in (STATE_OFF, STATE_IDLE, STATE_STANDBY):
            await self.async_turn_on()
        else:
            await self.async_turn_off()

I am now not sure if Cast integration should not use STATE_IDLE or that STATE_IDLE should not be considered Off.

I assume the latter since the frontend renders the mediaplayer card as On when the state is Idle.

If there is clarity on what should change I can make a PR to fix it.

mvdwetering avatar Aug 27 '22 15:08 mvdwetering

Just noticed that the media_player documentation says:

Entity is turned on and accepting commands, but currently not playing any media. Possibly at some idle home screen.

(could have sworn that was not there when I submitted this :/ )

So idle should not be in the Off state list.

mvdwetering avatar Sep 10 '22 14:09 mvdwetering

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.

github-actions[bot] avatar Dec 11 '22 06:12 github-actions[bot]

Mediaplayer Toggle service does still not work for Google cast in HA 2022.12.4

mvdwetering avatar Dec 14 '22 00:12 mvdwetering

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.

Still same issue with HA 2023.3.3

mvdwetering avatar Mar 14 '23 19:03 mvdwetering

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.

Still exists on HA 2023.6.1

mvdwetering avatar Jun 14 '23 18:06 mvdwetering

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.

Still exists on HA 2023.9.1

mvdwetering avatar Sep 13 '23 18:09 mvdwetering

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.

Still exists

mvdwetering avatar Dec 13 '23 20:12 mvdwetering

I seem to have a similar problem

leafney avatar Jan 16 '24 15:01 leafney

Doesn't turn off TV (only switches the HA and Chromecast wallpaper). Works like the 'Cast' button.

antivariant avatar Jan 23 '24 21:01 antivariant

I have similar problem. turn_off switches device to "Home Screen" and device is still on while HA shows media player off (grey card). It seems that if device has more services than only eg. playing media, the media_player.turn_off is turning of particular service that is in use but not power off the device. Calling turn_off again has no effect and device is still in "Home Screen". As it is commented above it might be that device is in idle state and accept only turn_on. This way HA is unable to turn device power off.

MG-PL-MG avatar Feb 28 '24 21:02 MG-PL-MG

Same issue here, chromecast not being turned off, just sent to idle screen.

sol3uk avatar Mar 06 '24 12:03 sol3uk

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.

Still there in HA core 2024.6.0

mvdwetering avatar Jun 07 '24 18:06 mvdwetering

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.

Still an issue in 2024.8.1.

Last time I will extend the stale notice, next time I will let it go. Someone else can take over.

mvdwetering avatar Sep 08 '24 12:09 mvdwetering

Still an issue in 2024.10.2.

why is this bug not fixed?

19Francesco81 avatar Oct 13 '24 21:10 19Francesco81

New user, same issue here. PR https://github.com/home-assistant/core/pull/78192 looks like it was shut down

NewAstronaut7451 avatar Nov 27 '24 14:11 NewAstronaut7451

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.

We should get this fixed

emontnemery avatar Mar 14 '25 14:03 emontnemery

Note that the linked PR won't work for all cast devices, the problem is that they simply can't be turned on or off.

emontnemery avatar Mar 14 '25 16:03 emontnemery