WTH Templates not evaluated everywhere

I’m fighting with templates not usable everywhere. To be honest not sure if this is pure HA issue, or the custom cards I’m using (mushroom)

just as an example: I’d like to have a single button with different action based on a entity state - if room lights are off, swith on the main light. If any light in the room is on, switch off everything (light group)

In developer tools this is working fine

data: {}
target:
  entity_id: '{{ "light.room_main" if states("light.grp_room") == "off" else "light.grp_room"}}'

(where light.room_main is the main light and light.grp_room is the group of all lights in the room.)

But trying to incorporate that to the UI with mushroom cards is a pain. The same goes to custom icon colors… (with an workaround by the mushroom template card).

Why the hell can’t the templates be used and evaluated simply anywhere?

Mushroom cards is a third party frontend module. You need to take this up with the developer.

Using the inbuilt button card I’ve got the same experience. Template is not evaluated.

- type: button
  entity: sensor.room_temperature
  name: Room
  show_name: true
  show_icon: true
  icon: mdi:desktop-classic
  show_state: true
  tap_action:
    action: call-service
    service: light.toggle
    data: {}
    target:
  	entity_id: >-
	    {{ "light.room_main" if states("light.grp_room") == "off" else "light.grp_room"}}
  hold_action:
    action: navigate
    navigation_path: room/

What am I doing wrong? Or is the original question valid? Why can’t the templates be used and evaluated simply anywhere?

Home Assistant’s standard cards don’t support templates (except for the Markdown card).

So the templates are just for scripts and automations? (and some custom cards, somewhere… but out of the pure HA scope). Pitty. It’s quite powerful.

Except for a few special cases templates can only be used under the following:

service:
data:
target:

service in dashboard card tap actions is not included (it used to be service_data).