iantrich / roku-card

📺 Roku Remote Card
MIT License
119 stars 41 forks source link

Add Support for Jinja OR Add configuration options for `action: toggle` #56

Closed traviscook21 closed 3 years ago

traviscook21 commented 3 years ago

I'd like to set up the mute button in the remote to mute a receiver that's playing the audio from the TV instead of the roku mute button.

I've tried the following options:

First, I thought maybe I could use the toggle action to flip the state of media.player.receiver, but there's not a way to specify a state attribute (like is_volume_muted)

tap_action:
    action: toggle

Then, I thought I could use call-service, but that only works to mute and now there's no way to unmute.

tap_action:
    action: call-service
    service: media_player.volume_mute
    service_data:
      entity_id: media_player.living_room_receiver
      is_volume_muted: True

I thought I could use Jinja to do this, but it won't let me save this. If I pass it as a string, I can save, but it doesn't render the string, so the value I'm passing isn't a boolean.

tap_action:
    action: call-service
    service: media_player.volume_mute
    service_data:
      entity_id: media_player.living_room_receiver
      is_volume_muted: {{ not state_attr('media_player.receiver', 'is_volume_muted') }}
iantrich commented 3 years ago

I will not implement either. Checkout config-template-card or lovelace-templater-card to use templates in a card