Lovelace name attribute code generated value possible

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

Core dashboard cards with few exceptions do not support templating. You will need a third party solution like this:

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 ?

I don’t use it. You’d be better off asking in the linked topic.

1 Like