Skip to content

Entity definitions

Entities are defined in the entities section of the Flexible Horseshoe Card.

In most cases, the only required field is the Home Assistant entity itself. The card then uses Home Assistant to fetch the default name, area, icon, unit, precision, state formatting, and localization.

This means a minimal entity definition can stay very small:

1
2
entities:
  - entity: sensor.memory_use_percent

The card will use the available Home Assistant metadata where possible. Depending on your Home Assistant language and locale settings, names, areas, states, numbers, and units are displayed using the configured localization.

You can override these values when needed. For example, you can set a custom name, use a different icon, change the number of decimals, display an attribute instead of the main entity state, or use a JavaScript template for dynamic entity values.

Basic usage

A basic entity definition only points to an entity:

1
2
entities:
  - entity: sensor.memory_use_percent

You can also define multiple entities. Layout sections such as states, names, areas, and icons can then refer to these entities by their entity_index.

Entities
1
2
3
4
5
6
7
- type: custom:flex-horseshoe-card
  entities:
    - entity: sensor.dsmr_reading_electricity_currently_delivered
    - entity: sensor.dsmr_reading_phase_currently_delivered_l1
    - entity: sensor.dsmr_reading_phase_currently_delivered_l2
    - entity: sensor.dsmr_reading_phase_currently_delivered_l3
    - entity: sensor.dsmr_reading_electricity_currently_delivered

The first entity has index 0, the second entity has index 1, and so on.

Entity metadata from Home Assistant

The card uses Home Assistant metadata as much as possible. This keeps your YAML shorter and helps the card behave consistently with the rest of your dashboard.

The following values can usually be taken from Home Assistant:

Value Description
Name The entity friendly name
Area The Home Assistant area assigned to the entity
State The current entity state
Unit The unit of measurement, such as kWh, W, %, or °C
Precision The number formatting or precision defined for the entity
Icon The entity icon, including state-based icons where supported
Icon color State-based icon color where Home Assistant provides it
Localization Translated names, states, and formatted numbers based on your Home Assistant locale

This is why you usually do not need to repeat the name, unit, icon, or precision unless you want to change how this specific card displays the entity.

Displaying an entity

You can override the default Home Assistant metadata in the entity definition.

Displaying an entity
1
2
3
4
5
6
entities:
  - entity: sensor.memory_use_percent
    decimals: 0
    icon: mdi:memory
    name: '5: RAM Usage'
    area: Hestia

In this example, the card uses a custom name, icon, area, and precision instead of relying fully on the Home Assistant defaults.

Displaying an attribute

An entity definition can also point to an attribute. This is useful for entities that expose several useful values, such as weather entities.

Displaying an attribute
1
2
3
4
5
6
7
entities:
  - entity: weather.dark_sky
    attribute: temperature
    units: '°C'
    icon: mdi:temperature
    decimals: 1
    name: 'Temperature'

You can also define several attributes from the same entity as separate entries:

Entities with attributes
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
- type: custom:flex-horseshoe-card
  entities:
    - entity: weather.zoefdehaas
      attribute: temperature
    - entity: weather.zoefdehaas
      attribute: humidity
    - entity: weather.zoefdehaas
      attribute: pressure
    - entity: sun.sun
      attribute: elevation
    - entity: sun.sun
      attribute: azimuth

Each entry receives its own entity_index, even when several entries use the same Home Assistant entity.

Overriding entity values

The card can use Home Assistant defaults automatically, but you can override them in the entities section when needed.

Entities with overrides
1
2
3
4
5
6
7
- type: custom:flex-horseshoe-card
  entities:
    - entity: sensor.dsmr_reading_electricity_currently_delivered
      name: "Total"
      decimals: 2
      icon: mdi:fire
      area: house

Common reasons to override values:

  • use a shorter name on a small card
  • show fewer or more decimals
  • use a custom icon
  • group an entity under a different area label
  • display an attribute with its own name and unit

Overriding entity formatting

v5.4.7-dev.7

The format option in the entities section allows you to override the default formatting of Home Assistant.

Remove separator and limit decimals
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
- type: custom:flex-horseshoe-card
  entities:
    - entity: sensor.dsmr_reading_electricity_currently_delivered
      name: "Total"
      icon: mdi:fire
      area: house
      format:
        separator: false    # Remove thousands separator
        decimals_min: 0     # minimal and...
        decimals_max: 2     # ... maximum number of digits
Display raw entity state as received from integration
1
2
3
4
5
6
7
8
9
- type: custom:flex-horseshoe-card
  entities:
    - entity: sensor.dsmr_reading_electricity_currently_delivered
      name: "Total"
      icon: mdi:fire
      area: house
      format:
        raw_state_keep: true  # Keep raw state. No formatting
        raw_state_clean: true # but remove underscores
Specify locale for translations and formatting
1
2
3
4
5
6
7
8
- type: custom:flex-horseshoe-card
  entities:
    - entity: sensor.dsmr_reading_electricity_currently_delivered
      name: "Total"
      icon: mdi:fire
      area: house
      format:
        locale: 'nl-NL' # Force presentation in dutch settings

Dynamic entity values

Some entity fields can also use JavaScript templates. This makes it possible to change parts of the entity definition based on the current state of an entity.

This is useful when a name, icon, area, unit, or other supported entity value should change dynamically instead of staying fixed.

For example, the name can depend on the state of another entity:

Dynamic entity name
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
- type: custom:flex-horseshoe-card
  entities:
    - entity: sensor.memory_use_percent
      name: |
        [[[
          const name = entities[1].state === 'on'
            ? '11: One Bulb ON'
            : '11: One Bulb OFF';
          return name;
        ]]]
      tap_action:
        action: more-info

    - entity: light.livingroom_light_duo_left_light
      name: 'hall'
      icon: mdi:lightbulb
      tap_action:
        action: call-service
        service: light.toggle
        service_data: { "entity_id" : "light.livingroom_light_duo_left_light" }

In this example, the first entity uses a dynamic name. The name changes depending on whether the second entity is on or not.

Dynamic templates can also be used for icons where supported:

Dynamic entity icon
1
2
3
4
5
6
7
8
9
entities:
  - entity: sensor.dsmr_reading_electricity_currently_delivered
    icon: |
      [[[
        const value = Number(state);
        return value >= 0.4
          ? 'mdi:flash'
          : 'mdi:flash-off';
      ]]]

Templates in the entities section use the same [[[ ... ]]] syntax as other JavaScript templates in the card.

Dynamic values are evaluated during updates

JavaScript templates are dynamic. They can react to entity states and may be evaluated again when the card updates.

This is different from static reuse features such as same_as, calc(), constants, and ref(), which are resolved during card setup.

For more details about JavaScript templates, available variables, and reusable template variables, see the templating page.

Available entity options

Name Type Required Description
entity string Home Assistant entity id
attribute string Attribute to display instead of the main entity state
unit string Unit to display for the entity or attribute. Can use a JavaScript template where supported
decimals number Number of decimals used to format the value
name string Custom name. Overrides the Home Assistant friendly name. Can use a JavaScript template where supported
area string Custom area. Overrides the Home Assistant area for this card. Can use a JavaScript template where supported
icon string Custom icon, image, SVG, or JavaScript template
format string Custom formatting of an entity state
tap_action object Action to run when the entity is clicked or tapped

Available entity format options

v5.4.7-dev.7

Name Type Required Description
separator boolean Enables/disables separator in numeric state
decimals_min number Minimal number of decimals used to format the value
decimals_max number Maximum number of decimals used to format the value
raw_state_keep boolean Keeps raw entity state if enabled. Prevents formatting or translations
raw_state_clean boolean Cleans raw entity states from underscores
locale string The locale in which you want the entity to be displayed

Icon options

If no icon is defined, the card uses the Home Assistant icon for the entity where possible.

You can override the icon with an MDI icon, an external image, an external SVG, or a JavaScript template.

Icon type Example Description
MDI icon icon: mdi:lightbulb Uses a Material Design icon
External image icon: url(/local/icons/icon-image.png) Uses an image file as the icon
External SVG icon: url(/local/icons/icon-svg.svg) Uses an SVG file as the icon
JavaScript template icon: | with [[[ ... ]]] Returns the icon dynamically

Tap actions

Use tap_action to define what should happen when the entity is clicked or tapped.

Name Type Default Options Description
action string more-info more-info, navigate, call-service, none Action to perform
service string none Any Home Assistant service Service to call when action is call-service
service_data object none Any service data Service data to include with the service call
navigation_path string none Any path Path to navigate to when action is navigate

Example: a light switch that toggles a light when tapped.

Light switch tap action
1
2
3
4
5
6
7
8
entities:
  - entity: light.1st_floor_hall_light
    name: 'hall'
    icon: mdi:lightbulb
    tap_action:
      action: call-service
      service: light.toggle
      service_data: { 'entity_id': 'light.1st_floor_hall_light' }

Entity layout elements

Defining an entity does not automatically show every part of that entity on the card. The entities section defines the data source. The layout sections decide which parts are shown and where they appear.

Entity part Layout section Description
Area areas Shows the Home Assistant area or custom area
Name names Shows the entity name or custom name
State states Shows the entity state, including unit and decimals
Icon icons Shows the entity icon or a standalone icon

For detailed configuration of areas, names, states, and icons, see Home Assistant Entity Elements.

For translated names and states, localized units, state colors, and number formatting, see Localization.