Just to be sure I am understanding mushroom correctly, I can only assume that anything in actions/tap actions cannot be templated variables. Simplified example:
decluttering_templates:
mode_chip:
card:
type: custom:decluttering-card
template: mode_chip_settings
variables:
- ip: '{{state_attr(''sensor.limitless_led_aliases'',''wifi_static_ip'')}}'
- device_id: >-
{{state_attr('sensor.limitless_led_aliases','group_id_aliases')[state_attr('[[entity]]','friendly_name')][1]}}
- remote_type: >-
{{state_attr('sensor.limitless_led_aliases','group_id_aliases')[state_attr('[[entity]]','friendly_name')][0]}}
- group_id: >-
{{state_attr('sensor.limitless_led_aliases','group_id_aliases')[state_attr('[[entity]]','friendly_name')][2]}}
- button: '[[button]]'
mode_chip_settings:
card:
type: custom:mushroom-chips-card
chips:
- type: template
entity: '[[entity]]'
icon: mdi:numeric-[[button]]
content_info: none
tap_action:
action: call-service
service: script.limitlessled_set_mode
service_data:
ip: '[[ip]]'
device_id: '[[device_id]]'
remote_type: '[[remote_type]]'
group_id: '[[group_id]]'
mode: '[[button]]'
mode_chip_test:
card:
type: markdown
content: '[[ip]], [[device_id]], [[remote_type]], [[group_id]], [[button]]'
views:
- title: Home
cards:
- type: custom:decluttering-card
template: mode_chip
variables:
- entity: light.pergola_leds
- button: 1
title: Regular Playground
From the above, I set several variables using templates in the decluttering template “mode_chip”.
Now if I use those variables to fill into a mushroom card inside a second decluttering template “mode_chip_settings” it does not work at all except for the icon populated from button.
Image of card:
Clicking results in this error:
Client error. Url: http://{{state_attr('sensor.limitless_led_aliases','wifi_static_ip')}}/gateways/{{state_attr('sensor.limitless_led_aliases','group_id_aliases')[state_attr('light.pergola_leds','friendly_name')][1]}}/{{state_attr('sensor.limitless_led_aliases','group_id_aliases')[state_attr('light.pergola_leds','friendly_name')][0]}}/{{state_attr('sensor.limitless_led_aliases','group_id_aliases')[state_attr('light.pergola_leds','friendly_name')][2]}}?blockOnQueue=true. Error: Cannot connect to host {{state_attr('sensor.limitless_led_aliases','wifi_static_ip')}}:80 ssl:default [Name or service not known]
Which is totally obvious that the strings that are templates are passed in and not the result of the templates. It is passiing in the string that represents the template but it does not get executed because mushroom does not allow templates for those fields.
However if I pass those exact same variables into markdown to be sure I got them correct, they work just fine. All I do is change the second template in the above example to “mode_chip_test”:
This shows that when used in markdown, the templated values are rendered, but used in a mushroom card inside tap_action, the templates are not executed.
Although maybe they would be if I used [[ … ]] and not {{ …}} as I would note that the error shows that [[entity]] was replaced. I just do not see how to execute it all.
I know I can pass in a simple string, because the colored dots in the image below use this:
type: custom:mushroom-chips-card
chips:
- type: entity
entity: '[[entity]]'
icon: none
content_info: none
tap_action:
action: call-service
service: light.turn_on
data:
transition: 0
brightness: 255
color_name: '[[colorname]]'
target:
entity_id: '[[entity]]'
So the “coloname” and “entity” passed in as simple strings work.
Is this correct?
Workaround ideas?
I have seen card-templater mentioned, but that does not work as far as I can see:
mode_chip:
card:
type: custom:card-templater
card:
type: custom:decluttering-card
template: mode_chip_test
variables:
- ip_template: '{{state_attr(''sensor.limitless_led_aliases'',''wifi_static_ip'')}}'
- device_id_template: >-
{{state_attr('sensor.limitless_led_aliases','group_id_aliases')[state_attr('[[entity]]','friendly_name')][1]}}
- remote_type_template: >-
{{state_attr('sensor.limitless_led_aliases','group_id_aliases')[state_attr('[[entity]]','friendly_name')][0]}}
- group_id_template: >-
{{state_attr('sensor.limitless_led_aliases','group_id_aliases')[state_attr('[[entity]]','friendly_name')][2]}}
- button: '[[button]]'
Results in this:
And I have no idea where the “-” comes from.
Note: I already use button-card templates for this and it is all fine, was just hoping for a mushroom-ized solution to make it easier to apply my card_mod animations.
Ultimately I was trying to make this all work 100% mushroom with nice animations. What is not done are the ten buttons in each row that set modes for the lights and control the speed of those lights: