Closed kingy444 closed 7 months ago
So a global value for media_player_id
that autopopulates any media player service calls similar to how the key
and source
work with remote_id
. I should probably also make it so that remote_id
autopopulates service calls as well. In order to prevent undesirable behavior, I'm going to also add a flag autofill_entity_id
which defaults to false which will enable this behavior for service calls.
@kingy444 this remote config is working for me as of the latest 3.5.3 alpha (alpha.015). Can you give it a try?
type: custom:android-tv-card
media_player_id: media_player.spotify
autofill_entity_id: true
rows:
- - slider
- previous
- next
- play_pause
custom_actions:
previous:
tap_action:
action: call-service
service: media_player.media_previous_track
play_pause:
tap_action:
action: call-service
service: media_player.media_play_pause
next:
tap_action:
action: call-service
service: media_player.media_next_track
slider:
style:
'--tooltip-label': '{{ (100 * VALUE) | int }}%'
Because this release has a bunch of small feature requests I've bumped the version up to 3.6.0 and put a beta out. Let me know if it looks good to you!
@kingy444 if you have no comments on this feature implementation and that for #74 I'm going to release it in the next few days.
@kingy444 if you have no comments on this feature implementation and that for #74 I'm going to release it in the next few days.
Sorry for not getting back to you
I've been away and will hopefully be able to check it later tonight/tomorrow
One drawback I just noticed is that I only have it autofilling for services with domain remote
or media_player
, but here are other services like kodi
and denonavr
which wouldn't be covered by this. I'm not sure if I should reconsidered how I'm selecting which service calls get autofilled or add kodi
and denonavr
services to the list of services autofilled using media_player_id
.
Edit: Making it so that Kodi and DenonAVR service calls use media_player_id
when autofill_entity_id
is true is trivial so I'm going to do that.
Seems to work well from my testing
Is there a way to access this entity is in jinja2 like the below?
power:
style:
color: |
{% if is_state("media_player.lounge_tv", "on") %}
rgb(229,9,20)
{% else %}
rgb(68, 163, 69)
{% endif %}
This card supports templating via nunjucks, which has 99% the same syntax as jinja2 but is made for JavaScript. That template should work as is with this card.
Optional autofilling of service call entity IDs using remote or media player ID added in 3.6.0.
This card supports templating via nunjucks, which has 99% the same syntax as jinja2 but is made for JavaScript. That template should work as is with this card.
You are correct in it works as is but I was looking to make this dynamic
What I am asking is how do I replace media_player.lounge_tv
with the new global entity id. Is there a way to access the media_player_id
value within the nunjucks ?
There isn't, but I did recently do some refactors to how templates are processed internally to include more internal context. If you create another feature request we can discuss more internal fields to be accessible by templates.
Is your feature request related to a problem? Please describe.
More of a code clean up (yaml) request and easy of changing devices. You have entity definitions for remote_id and slider_id. Could we have a new entity definition field that can be used as "default for custom calls"
Describe the solution you'd like I am thinking at the top of the card we can define something like
media_player_id: media_player.lounge_tv
then rather then having to change all
tap_action
as belowthey could be defined as something like the below
Essentially then when you build the service call do something like