kalkih / mini-media-player

Minimalistic media card for Home Assistant Lovelace UI
MIT License
1.51k stars 206 forks source link

Template used in shortcut source gives strange result #611

Closed GitHubRousseau closed 2 years ago

GitHubRousseau commented 2 years ago

There seams to big a bug when using template in source of a shortcut button. It behaves exactly like if it was adding not printable characters.

My config is:

type: custom:mini-media-player entity: media_player.tv_player volume_step: '1' max_volume: '100' min_volume: '0' source: full hide: icon_state: false play_pause: true prev: true next: true toggle_power: false shortcuts: columns: 6 buttons:

input_text.mp_source_box has for value "TV Box"

media_player.tv_player is a universal media player is the change of source is calling a script.

With the script I check the value parsed to source when I click the first button. When sent to my phone it appears to be "TV Box" which looked good. But, the script when I compare it to "TV Box" is says it's different.

I did the following test. I replaced the config with. - icon: mdi:television-box type: source id: TV Box It worked fine. Proper display on my phone and script sees it as equal to "TV Box".

I came to the conclusion that, when I use a template it seem to add hidden characters because the display is correct but the comparison by the script doesn't match the text.

After further research i did a text by sending to my phone the urlencode version. It was %7B%7B%20states%28%27input_text.mp_source_box%27%29%20%7D%7D. It seems that the template was not evaluated. It's only when I send it to notify that I get a full evaluation.

kalkih commented 2 years ago

Hey, Templating in the card configuration is not supported in mini-media-player. Cards with template support has custom logic implemented in order to handle it.

I currently have no plans to support templating in this card. You could however have template support in any card by utilizing https://github.com/iantrich/config-template-card Hope this helps.