Hi I would like to name some entities with dynamic name to be displayed on the lovelace card.
So I have some entities that are daily and are represented by D1,D2 etc which means day 1, day 2 of the week etc, but the “day of the week” which these refer to changes each day.
In lovelace I wanted to name the entities to show the day of the week, I tried for example
entity: sensor.solcast_forecast_d3
name: {{(now()+ timedelta(days=3)).strftime("%a")}}
but that just displays [object Object]
is there a way to do this?
Thanks
Mark
tom_l
August 10, 2023, 9:19am
2
Core dashboard cards with few exceptions do not support templating. You will need a third party solution like this:
Lovelace Templates
I’ve gone and made a crazy card that allows you to pretty much template anything in Lovelace for your card configurations using any information available on the frontend; states, attributes, user, etc.
Want state/attribute-based icons? DONE!
Want dynamic stacks; vertical vs horizontal based on user? DONE!
Want OR conditionals? DONE!
The list is pretty much endless and I’m sure you all will come up with some crazy stuff. Be sure to share.
Go nuts! Enjoy!
1 Like
Hi @tom_l so I gave it a go and tried the following:
type: custom:config-template-card
entities:
- sensor.solcast_forecast_d3
card:
type: entities
entities:
- entity: sensor.solcast_forecast_d3
name: Test1
- entity: sensor.solcast_forecast_d3
name: "${ (now()+timedelta(days=2)).strftime('%a') }"
and this
type: custom:config-template-card
variables:
TEST: "{ (now()+timedelta(days=2)).strftime('%a') }"
entities:
- sensor.solcast_forecast_d3
card:
type: entities
entities:
- entity: sensor.solcast_forecast_d3
name: Test1
- entity: sensor.solcast_forecast_d3
name: ${TEST}
funny if I set the TEST variable to something like “{ 4+3 }” is evaluates and seems to work.
but if I add the bottom name: attribute value it does nothing, in fact it blanks the entire card, what am I doing wrong ?
tom_l
August 10, 2023, 10:41am
4
I don’t use it. You’d be better off asking in the linked topic.
1 Like