Open LDprg opened 7 months ago
This is a mod of a pop-up card I have. Includes some sample sensors and also markdown.
For me it works
show_name: true
show_icon: true
type: button
tap_action:
action: fire-dom-event
browser_mod:
service: browser_mod.popup
data:
title: Tank heater contactor control
content:
type: vertical-stack
cards:
- type: entities
title: Title 1
show_header_toggle: false
theme: my_theme
entities:
- entity: sensor.sensor_1
name: Name for sensor 1
secondary_info: last-updated
- entity: sensor.sensor_2
name: Name for sensor 2
secondary_info: last-updated
- type: markdown
title: My markdown name
content: >-
Your markdown text goes here
Your markdown text goes here
Your markdown text goes here
name: Name for the card
show_state: true
icon: mdi:something
icon_height: 40px
@LDprg I was having an issue recently where content in my markdown card would be blank when executed from a script in a pop-up. If I ran the script manually, the pop-up would appear and the markdown would be displayed. Drove me nuts for several days and when the automation ran (to launch the pop-up service), all I got was this:
I found a closed bug here that mentioned wrapping the markdown in {% raw %}
and {% endraw %}
and that worked!
N.B It was working without the raw
wrapping until a recent Home Assistant update sometime in April I think so don't know what changed.
- type: conditional
conditions:
- condition: numeric_state
entity: sensor.flightradar24_current_in_area
above: 0
card:
type: markdown
content: >-
{% raw %} {% set data =
state_attr('sensor.flightradar24_current_in_area', 'flights') %} {% for
flight in data %}
<ha-icon icon="mdi:airplane"></ha-icon>{{ flight.flight_number }}({{ flight.aircraft_registration }}) - {{ flight.airline_short }} - {{ flight.aircraft_model }}
{{ flight.airport_origin_city }}{%if flight.airport_origin_city %}<img src="https://flagsapi.com/{{ flight.airport_origin_country_code }}/shiny/16.png" title='{{ flight.airport_origin_country_name }}'/>{% endif %} -> {{ flight.airport_destination_city }}{%
if flight.airport_destination_country_code %}<img src="https://flagsapi.com/{{ flight.airport_destination_country_code }}/shiny/16.png" title='{{ flight.airport_destination_country_name }}'/>{% endif %}
{%if flight.time_scheduled_departure %}Departure - {{ flight.time_scheduled_departure | timestamp_custom('%H:%M') }}; {% endif %}{%if flight.time_scheduled_arrival%}Arrival - {{ flight.time_scheduled_arrival | timestamp_custom('%H:%M') }}{% endif %}
Altitude - {{ flight.altitude }} ft{%if flight.altitude > 0 %} ({{(flight.altitude * 0.3048)| round(0)}} m){% endif%}; Gr. speed - {{ flight.ground_speed }} kts{%if flight.ground_speed > 0 %} ({{(flight.ground_speed * 1.852)| round(0)}} km/h){% endif%}
{% endfor %}
{% endraw %}
@LDprg I was having an issue recently where content in my markdown card would be blank when executed from a script in a pop-up. If I ran the script manually, the pop-up would appear and the markdown would be displayed. Drove me nuts for several days and when the automation ran (to launch the pop-up service), all I got was this:
I found a closed bug here that mentioned wrapping the markdown in
{% raw %}
and{% endraw %}
and that worked! N.B It was working without theraw
wrapping until a recent Home Assistant update sometime in April I think so don't know what changed.- type: conditional conditions: - condition: numeric_state entity: sensor.flightradar24_current_in_area above: 0 card: type: markdown content: >- {% raw %} {% set data = state_attr('sensor.flightradar24_current_in_area', 'flights') %} {% for flight in data %} <ha-icon icon="mdi:airplane"></ha-icon>{{ flight.flight_number }}({{ flight.aircraft_registration }}) - {{ flight.airline_short }} - {{ flight.aircraft_model }} {{ flight.airport_origin_city }}{%if flight.airport_origin_city %}<img src="https://flagsapi.com/{{ flight.airport_origin_country_code }}/shiny/16.png" title='{{ flight.airport_origin_country_name }}'/>{% endif %} -> {{ flight.airport_destination_city }}{% if flight.airport_destination_country_code %}<img src="https://flagsapi.com/{{ flight.airport_destination_country_code }}/shiny/16.png" title='{{ flight.airport_destination_country_name }}'/>{% endif %} {%if flight.time_scheduled_departure %}Departure - {{ flight.time_scheduled_departure | timestamp_custom('%H:%M') }}; {% endif %}{%if flight.time_scheduled_arrival%}Arrival - {{ flight.time_scheduled_arrival | timestamp_custom('%H:%M') }}{% endif %} Altitude - {{ flight.altitude }} ft{%if flight.altitude > 0 %} ({{(flight.altitude * 0.3048)| round(0)}} m){% endif%}; Gr. speed - {{ flight.ground_speed }} kts{%if flight.ground_speed > 0 %} ({{(flight.ground_speed * 1.852)| round(0)}} km/h){% endif%} {% endfor %} {% endraw %}
You, sir, are a legend. I know you just looked at a closed issue, but I never would have thought to do that. I would have seen this issue and thought "oh, it's not just me, they're working on it" and stopped there. Thank you so much, I have no idea why this works, but it sure does. How would someone even think to try this?
I didn't have this exact issue, but my markdown card wouldn't refresh. Maybe this will help someone else too.
My Home Assistant version: 2024.2.1
What I am doing: Adding a Markdown card to a popup card causes it to be empty. Static text and Templates wont work.
What I expected to happen: The markdown card to work as expected like everywhere else.
What happened instead: Well no visible markdown card/content.
Minimal steps to reproduce:
Error messages from the browser console:
Nothing special here.
By replacing the space in the checkboxes ([ ]) with an X below, I indicate that I:
[x] Understand that this is a channel for reporting bugs, not a support forum (https://community.home-assistant.io/).
[x] Have made sure I am using the latest version of the plugin.
[x] Have followed the troubleshooting steps of the "Common Problems" section of https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins.
[x] Understand that leaving one or more boxes unticked or failure to follow the template above may increase the time required to handle my bug-report, or cause it to be closed without further action.