Skip to content

tonywheeler60/lovelace-template-entity-row

 
 

Repository files navigation

template-entity-row

hacs_badge

Display whatever you want in an entities card row.

For installation instructions see this guide.

Install template-entity-row.js as a module.

resources:
  - url: /local/template-entity-row.js
    type: module

Usage example

Note: This is not a card. It's a row for an entities.

Skärminspelning 2020-01-03 kl  23 03 16 mov

type: entities
title: Default
entities:
  - light.bed_light
  - entity: input_boolean.car_home
  - type: custom:template-entity-row
    icon: mdi:lamp
    name: "The light is {{states('light.bed_light')}} but nobody's"
    state: "{% if is_state('input_boolean.car_home', 'on')%} home {% else %} away {% endif %}"
    secondary: "It's {{states('sensor.time')}}"
    active: "{{ is_state('light.bed_light', 'off') }}"
  - type: custom:template-entity-row
    icon: mdi:car
    name: Hi there
    condition: "{{is_state('input_boolean.car_home', 'on')}}"

Options

  • icon, name, state, secondary, image selects what icon, name, state, secondary_info text and entity_picture to display respectively.
  • active if this evaluates to "true", the icon gets the color --paper-item-icon-active-color. Otherwise --paper-item-icon-color.
  • entity if this evaluates to an entity id, icon, name, state and image will be taken from that entity unless manually overridden. Specifying an entity will also let you use action.
  • condition if this is set but does not evaluate to "true", the row is not displayed.
  • toggle if this evaluates to "true" a toggle is shown instead of the state. The toggle is connected to the entity.
  • tap_action, hold_action, double_tap_action: see below.

All options accept jinja2 templates.

Jinja templates have access to a few special variables. Those are:

  • config - an object containing the card configuration
  • user - the username of the currently logged in user
  • browser - the deviceID of the current browser (see browser_mod).
  • hash - the hash part of the current URL.

In evaluated templates the function _(<key>) (underscore) will localize the <key> to the current language. E.g. _(state.binary_sensor.motion.off) will be replaced with Clear if your language is set to English.

To find the available keys, open your browsers console, type in the following and press Enter:

document.querySelector("home-assistant").hass.resources;

Actions

tap_action, hold_action and double_tap_action can be templated if the template evaluates to a valid action configuration in python format. Standard YAML without templates works too.

Eg:

type: custom:template-entity-row
entity: light.bed_light
# Standard yaml configuration - No templates allowed
hold_action:
  action: more-info
# JSON return format
tap_action: |
  {
    "action": "toggle",
    "confirmation": {
      "text": "Do you really want to turn {{ state_attr(config.entity, 'friendly_name') }} {% if is_state(config.entity, 'on') %}off{% else %}on{% endif %}?",
    },
  }
double_tap_action:
  action: toggle

FAQ

Why does this look weird?

Because you're not using it correctly. This is not a card. It's an entity row, and is meant to be used inside the entities card


Buy Me A Coffee

About

🔹 Display whatever you want in an entities card row.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 92.0%
  • JavaScript 6.8%
  • Shell 1.2%