Skip to content

Add condition to call the toggle service for media_players#4250

Closed
ktnrg45 wants to merge 2 commits into
home-assistant:devfrom
ktnrg45:media-player
Closed

Add condition to call the toggle service for media_players#4250
ktnrg45 wants to merge 2 commits into
home-assistant:devfrom
ktnrg45:media-player

Conversation

@ktnrg45
Copy link
Copy Markdown
Contributor

@ktnrg45 ktnrg45 commented Nov 20, 2019

Partial fix for Issue: home-assistant/core#28891.
Don't close issue.

Add condition to call the media_player entity's toggle service if turn on and turn off are both supported. This allows for the turn off/turn on logic to be handled in the backend via the toggle service.

Comment thread src/util/hass-media-player-model.js
@ktnrg45 ktnrg45 marked this pull request as ready for review November 20, 2019 12:26
@ktnrg45 ktnrg45 changed the title [WIP] Add standby state to media_player Add standby state to media_player Nov 20, 2019
@ktnrg45 ktnrg45 changed the title Add standby state to media_player [WIP] Add standby state to media_player Nov 21, 2019
@ktnrg45 ktnrg45 changed the title [WIP] Add standby state to media_player Add standby state to media_player Nov 21, 2019
Copy link
Copy Markdown
Member

@bramkragten bramkragten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is standby an official state of the media player domain?

EDIT: Guess we'll wait for home-assistant/core#28897

@ktnrg45
Copy link
Copy Markdown
Contributor Author

ktnrg45 commented Nov 30, 2019

Is standby an official state of the media player domain?

EDIT: Guess we'll wait for home-assistant/home-assistant#28897

Yes that would be preferable. Thanks for the approve!

@bramkragten
Copy link
Copy Markdown
Member

Has there already been an architecture issue for adding the standby state?

@frenck
Copy link
Copy Markdown
Member

frenck commented Jan 8, 2020

Just this one: home-assistant/architecture#327 Which has been closed by the author.

The parent PR in the backend is closed as well.

@ktnrg45
Copy link
Copy Markdown
Contributor Author

ktnrg45 commented Jan 8, 2020

Reopened architecture issue. Was going to just do a revert to resolve the backend issue which is why I closed it.

@iantrich
Copy link
Copy Markdown
Member

@ktnrg45 is there a backend change pending then?

@ktnrg45
Copy link
Copy Markdown
Contributor Author

ktnrg45 commented Jan 24, 2020

@ktnrg45 is there a backend change pending then?

No not currently.

Comment thread src/util/hass-media-player-model.js
@fleXible
Copy link
Copy Markdown

@ktnrg45 just gave my 2 cents in home-assistant/core#28891 to the whole thing, because I already put quite some time into this issue and now ended up monkey patching the pieces with a custom_component because lovelace UI, an mini-media-player custom UI and homekit are broken and no fix in sight.
I'm really interested in getting this thing properly done!

btw. I also stumbled over this select_source thing you describe, even worse, when using homekit the UI part is disabled and because the source attribute is missing in STATE_OFF, there's this nasty Sources out of sync. Restart Home Assistant error.

@ktnrg45
Copy link
Copy Markdown
Contributor Author

ktnrg45 commented Feb 22, 2020

@ktnrg45 just gave my 2 cents in home-assistant/home-assistant#28891 to the whole thing, because I already put quite some time into this issue and now ended up monkey patching the pieces with a custom_component because lovelace UI, an mini-media-player custom UI and homekit are broken and no fix in sight.
I'm really interested in getting this thing properly done!

btw. I also stumbled over this select_source thing you describe, even worse, when using homekit the UI part is disabled and because the source attribute is missing in STATE_OFF, there's this nasty Sources out of sync. Restart Home Assistant error.

Ok I just saw your comment here. Yeah I think using toggle would be best. Ill change it to this tonight.

@fleXible
Copy link
Copy Markdown

@ktnrg45 Nice! But watch out for is_on property, which is how ToggleEntity decides how to switch.

In my opinion, a well chosen and unambiguous way to do so. But nearly nobody with a media_player has it yet.

But it has to be implemented now for it to work.

@ktnrg45 ktnrg45 changed the title Add standby state to media_player Add condition to call the toggle service for media_players Feb 22, 2020

togglePower() {
if (this.isOff) {
if (this.supportsTurnOn && this.supportsTurnOff) {
Copy link
Copy Markdown
Contributor Author

@ktnrg45 ktnrg45 Feb 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition may not be necessary, we may be able to simply call toggle(). The Plex integration seems to be the only media_player that supports 'turnoff' but not 'turnon'. Used grep -rl 'SUPPORT_TURN_ON' homeassistant/components/*/media_player.py

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly the Plex integration should probably not advertise as supporting either power on/off as it doesn't have the ability to do either.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more that can't turn on. Philips js, arcam. They can support it with external wol or it blasters.

@ktnrg45
Copy link
Copy Markdown
Contributor Author

ktnrg45 commented Feb 22, 2020

@bramkragten Sorry about taking so long to resolve this. I've changed this PR so that the toggle service would be called instead so that the backend would handle the toggling.

@bramkragten
Copy link
Copy Markdown
Member

This PR is no longer current with the recent changes in the media control card. Please create a new PR if needed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants