Entity state (not state attribute) in a lovelace markdown card

Dear anyone,

I have (basically through copy-pasting) added some current information to a dashboard in a Markdown card.

{{ state_attr('weather.forecast_myhome' , 'temperature') }} °C

results in 22.8 °C on the card
What I understand about this is that we need {{ }} to get a reference to a home assistant entity into the markdown card. and that state_attr makes the reference more specific into the attribute "temperature’ belonging to the entity "weather.forecast_myhome’

When I go to the Developer tools and look for the Forecast MyHome entity, it says the state is cloudy . (And I can find the names of many other attributes.

What I cannot do is find a way to reference the basic state of the entity into my markdown card.
I have tried about 50 ways to use ‘state_attr’, it just won’t work.
I have seen that another attribute is “forecast” which then has an additional list of sub-attributes like “condition” (which is still cloudy, but at a later time)
So I have tried to use “condition” as a “state_attr”

{{ state_attr('weather.forecast_myhome' , 'condition') }}

but it won’t work.

What is the syntax to get to the basic “state” of the entity ?
What is the syntax (if that is at all possible) to get to the states and attributes of the forecasts ?

Thanks

{{ states('weather.forecast_myhome') }}
1 Like

You should read:

Templating - Home Assistant (home-assistant.io)

1 Like

I was 100% sure I tried that.
May have spelled it “state” rather than “states” … since cloudy seems to be a single state.

Thanks !!

I honestly had no idea it was called “templating”
Thanks for the link.

{{ state_attr(entity_id, 'friendly_name') }} - {{ states(entity_id) }}

has both state_attr and states

There is even a “template editor tool” that has almost exactly what I was looking for.

But why doesn’t the developer-states-tool refer to it as “states” anywhere. It refers to that piece of data as “state”, which makes sense.
Navigating the manuals is very confusing and frustrating sometimes.

:slight_smile: