Do I need to have "-entity:" in the dashboard code after "entities"?

Looking at the dashboard code there is - entity: in front of the sensor.

type: entities
entities:
  - entity: sensor.memory_use_percent
  - entity: sensor.memory_use
  - entity: sensor.memory_free
title: Memory

Is -entity required? I removed it and it seems to work fine. The config code now looks the following way:

type: entities
entities:
  - sensor.memory_use_percent
  - sensor.memory_use
  - sensor.memory_free
title: Memory

As you’ve seen, it works either way. However, the second way is just a list of entities and you can’t customise how they’re displayed, what they do when you click on them etc. The first way, using an entity object for each sensor, gives you more control.

Entities Card - Home Assistant (home-assistant.io)

1 Like

Yep you only need to use - entity: if you want to customise the way the entity is displayed (e.g. change the displayed name, icon etc…).

valid:

type: entities
entities:
  - entity: sensor.memory_use_percent
    name: Memory Pct
  - entity: sensor.memory_use
    icon: "mdi:gauge"
  - entity: sensor.memory_free
    secondary_info: last_changed
title: Memory

Not valid:

type: entities
entities:
  - sensor.memory_use_percent
    name: Memory Pct
  - sensor.memory_use
    icon: "mdi:gauge"
  - sensor.memory_free
    secondary_info: last_changed
title: Memory

Note that changing things like icon and name here only change the display of that one instance in the card. They do not update the entity. I find it handy for displaying abbreviated names in dashboards created for small displays (mobile devices) without affecting my main dashboard cards.