Skip to content

jenseo/config-template-card

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

58 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Config Template Card Card

๐Ÿ“ Templatable Configuration Card

GitHub Release License hacs_badge

Project Maintenance GitHub Activity

Discord Community Forum

Twitter Github

This card is for Lovelace on Home Assistant that allows you to use pretty much any valid Javascript on the hass object in your configuration

Minimum Home Assistant Version

Home Assistant version 0.110.0 or higher is required as of release 1.2.0 of config-template-card

Support

Hey dude! Help me out for a couple of ๐Ÿป or a โ˜•!

coffee

Installation

Use HACS or follow this guide

resources:
  - url: /local/config-template-card.js
    type: module

Options

Name Type Requirement Description
type string Required custom:config-template-card
card object Required Card object
entities list Required List of entity strings that should be watched for updates. Templates can be used here
variables list/object Optional List of variables, which can be templates, that can be used in your config and indexed using vars or by name

Available variables for templating

Variable Description
this.hass The hass object
states The states object
user The user object
vars Defined by variables configuration and accessible in your templates to help clean them up. If variables in the configuration is a yaml list, then vars is an array starting at the 0th index as your firstly defined variable. If variables is an object in the configuration, then vars is a string-indexed map and you can also access the variables by name without using vars at all.
type: 'custom:config-template-card'
variables:
  LIGHT_STATE: states['light.bed_light'].state
  GARAGE_STATE: states['cover.garage_door'].state
entities:
  - light.bed_light
  - cover.garage_door
  - alarm_control_panel.alarm
  - climate.ecobee
card:
  type: "${LIGHT_STATE === 'on' ? 'glance' : 'entities'}"
  entities:
    - entity: alarm_control_panel.alarm
      name: "${GARAGE_STATE === 'open' && states['alarm_control_panel.alarm'].state === 'armed_home' ? 'Close the garage!' : ''}"
    - entity: binary_sensor.basement_floor_wet
    - entity: climate.ecobee
      name: "${states['climate.ecobee'].attributes.current_temperature > 22 ? 'Cozy' : 'Too Hot/Cold'}"
    - entity: cover.garage_door
    - entity: "${LIGHT_STATE === 'on' ? 'light.bed_light' : 'climate.ecobee'}"
      icon: "${GARAGE_STATE === 'open' ? 'mdi:hotel' : '' }"

Templated entities example

type: 'custom:config-template-card'
variables:
  - states['sensor.light'].state
entities:
  - '${vars[0]}'
card:
  type: light
  entity: '${vars[0]}'
  name: "${states[vars[0]].state === 'on' ? 'Light On' : 'Light Off'}"

Note: All templates must be enclosed by ${}

Troubleshooting

Developers

Fork and then clone the repo to your local machine. From the cloned directory run

npm install && npm run build

About

๐Ÿ“ Templatable Lovelace Configurations

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 74.2%
  • JavaScript 25.8%