Open rjgrandy opened 10 months ago
Hi there,
Not sure if this is what you mean but i think i'm kinda doing the same
This is my room_card.yaml function
# lovelace_gen
type: custom:mushroom-template-card
entity: {{ room_state_group }}
primary: {{ room|capitalize }}
secondary: |-
{%raw%}
{% if is_state('{%endraw%}{{ room_state_group }}{%raw%}', 'on') %}
Aan
{% else -%}
Uit
{%- endif -%}
{%endraw%}
icon: {{ icon }}
icon_color: |-
{%raw%}
{% if is_state('{%endraw%}{{ room_state_group }}{%raw%}', 'on') %}
yellow
{%- endif -%}
{%endraw%}
tap_action:
action: navigate
navigation_path: {{ room }}
layout: horizontal
hold_action:
action: toggle
double_tap_action:
action: none
fill_container: true
In my view i'm using this to "call the function":
- type: horizontal-stack
cards:
- !include
- ../../functions/room_card.yaml
- room: achtertuin
room_state_group: light.achtertuin_light_group
icon: mdi:palm-tree
- !include
- ../../functions/room_card.yaml
- room: schuur
room_state_group: light.schuur_licht
icon: mdi:barn
Which is resulting in (the bottom two buttons):
For the entity i'm using a different name than "Entity". Don't know or it might be an issue but in my case I often use groups to show the state.
Hope this helps you?
I want to populate a template card (mushroom template) using lovelace_gen. So I need to escape the parts that I want jinja to pass through with {% raw %}, however I want to use a variable from lovelace_gen (in the below case {{entity}}. Is below an acceptable syntax? I doesn't seem to like it.