Markdown card is acting up

I have a sensor with some attributes that are actually just hour numbers, like

hour_1: 8
hour_2: 9
hour_3: 10
hour_4: 11

I am trying to extract these values and show them on a markdown card, but its acting up.

If I do below setup I get nothing out.

type: markdown
content: >-
 {{ state_attr('sensor.weather_birkerod_hours_forecast','day0_2_hour') }}

If I do below, which have just an added h, then I get both the sensor value and the h printed out.

type: markdown
content: >-
 {{ state_attr('sensor.weather_birkerod_hours_forecast','day0_2_hour') }} h

If I do below, where I try to get a leading 0 on single digit values, then I get the single digit values with the leading 0 printed, but the double digit that require no leading 0 will not be printed.

type: markdown
content: >-
 {{ state_attr('sensor.weather_birkerod_hours_forecast','day0_2_hour') | timestamp_custom('%S') }}

It does not matter if the output of the sensor are set as numbers or as text with qoutes around.

I am trying to just get the numbers with maybe a leading 0.
I am thinking about a fake conversion or something like that, to get around the bug, but I am not sure what is possible in those embedded code lines in the card configuration.
I hope someone can come up with a way forward.

Thanks.

Yep, looks like a bug.
If the full content of the template can be reduced to an int or float, then nothing is shown, as you noticed.

As you also noticed, adding any string, maybe the unit, here, will workaround the issue.

1 Like

To others with this problem.
The solution is to add the font html tag around it, like this:

<font>{{ state_attr('sensor.my_sensor','some_data') }}</font>

I can confirm that it’s misbehaving the way you described. As long as something else is present with the numeric value (other than a space character) it will then display the numeric value, otherwise it won’t. Definitely a bug.

Or just like this.

Issue created: