EDIT: I’m still interested in the answer to this but is so often the case in HA dashboards, if there is a problem, the answer is usually custom:button-card
I just replaced my markdown card with a button-card and all is good.
I think I’ve found an issue with using the markdown card in a custom:button card.
I should add here that this is also using lovelace_gen which might complicate things…
The problem is very simple to describe.
I don’t seem to be able to pass a variable into a markdown card without getting the dreaded
This is the first time I have had any trouble doing this kind of thing and I do it a lot in my config in other cards so I am just wondering if this is indeed a limitation and I should stop banging my head against the wall or am I somehow doing something wrong?
As simply as I can (and removing anything irrelevant e.g. styling) I have this:
type: entities
entities:
- type: custom:hui-element
card_type: horizontal-stack
cards:
- !include
- /config/lovelace/dashboard_home/sonos/sonos_button.yaml
- room: kitchen
sonos_button.yaml
Firstly to demonstrate the principle - this works
type: custom:button-card
entity: media_player.sonos_{{ room }}
tap_action:
action: fire-dom-event
browser_mod:
service: browser_mod.popup
data:
title: SONOS - {{ room }}
content:
type: vertical-stack
cards:
- type: entities
entities:
- type: custom:hui-element
card_type: custom:mini-media-player
entity: media_player.sonos_{{ room }}
- type: custom:hui-element
card_type: markdown
content: >
TEST
- entity: sensor.sonos_{{ room }}_lyrics
type: attribute
attribute: plainLyrics
All of these produce the same “Unknown error” error:
(I have also tried moving the markdown into a separate file and including it but that also didn’t work.)
type: vertical-stack
cards:
- type: entities
entities:
- type: custom:hui-element
card_type: custom:mini-media-player
entity: media_player.sonos_{{ room }}
- type: custom:hui-element
card_type: markdown
content: >
{% if is_number(states('sensor.sonos_{{ room }}_lyrics')) %}
{{ state_attr('sensor.sonos_{{ room }}_lyrics', 'plainLyrics') }}
{% else %}
{{ states('sensor.sonos_{{ room }}_lyrics') }}
{% endif %}
content: >
{% raw %}
{% set room = %} {% endraw %} {{ room }} {% raw %} %}
{% endraw %}
{% if is_number(states('sensor.sonos_' ~ room ~ '_lyrics')) %}
{{ state_attr('sensor.sonos_' ~ room ~ '_lyrics', 'plainLyrics') }}
{% else %}
{{ states('sensor.sonos_' ~ room ~ '_lyrics') }}
{% endif %}
