Nerwyn / android-tv-card

A completely customizable universal remote card for Home Assistant. Supports multiple platforms out of the box.
Apache License 2.0
243 stars 12 forks source link

Template Support for Custom Keys #34

Closed Ayuus closed 10 months ago

Ayuus commented 11 months ago

Hello,

I expected that custom buttons would allow me to write a template, so I tried to implement a toggle button for muted audio:

custom_keys:
  my_volume_mute:
    icon: mdi:volume-high
    service: media_player.volume_mute
    target:
      entity_id: media_player.lg_tv
    data:
      is_volume_muted: "{{ not state_attr('media_player.lg_tv', 'is_volume_muted') }}"

However, HA c omplains about "invalid value for Boolean". In Developer Tools, Templates, the code works OK.

Nerwyn commented 11 months ago

This card does not support jinja templates. Once I figure out how to add template support, I'll do so.

Ayuus commented 11 months ago

OK, clear. Any other way to implement mute/unmute via toggle button?

Nerwyn commented 11 months ago

The media_player.volume_mute service should already be a toggle, but I guess the behavior be different for LG webOS. Unfortunately until I figure out jinja template support (I'm out of town for a week and won't be able to work on it for a while) you'd need two separate buttons. You could make it so that this button always mutes and the volume up/down buttons should unmute it (unless LG webOS behaves differently).

thegreekgeek commented 10 months ago

I'd also appreciate this, I'm trying to selectively enable my theater mode automation and there's no feedback to the toggle.

schmierlappe commented 10 months ago

would also love this for the styling section

Nerwyn commented 10 months ago

I got nunjucks (jinja2 for JavaScript that's 99% the same thing) template support working in my other project. Once I finish updating that I'll work on adding it to this one. ETA would be a week or so.

Nerwyn commented 10 months ago

Template support has been added in v3.1.0. It works for everything in the card - icons, row entries, styles, service call data, etc.

Ayuus commented 10 months ago

Works great, thx!