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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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 | |
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¶
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 | |
| Display raw entity state as received from integration | |
|---|---|
1 2 3 4 5 6 7 8 9 | |
| Specify locale for translations and formatting | |
|---|---|
1 2 3 4 5 6 7 8 | |
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 | |
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 | |
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¶
| 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 | |
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.