• Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 5 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Custom, "neumorphism" Lovelace card

Project logo

Button Text Card

hacs_badge Build Status GitHub Issues GitHub Pull Requests License


Custom, "neumorphism" card for Home Assistant with support for templating.

Table of contents


Installation instructions

  1. Open HACS
  2. Go to Plugins > Search for "Button Text Card"
  3. Install it
  4. Add to your Lovelace config:
  - url: /hacsfiles/button-text-card/button-text-card.js
    type: module

Configuration options

Name Type Requirement Description Default Template support?
type string required custom:button-text-card n/a No
entity string optional Which entity state you want to use in your card (templating) No
icon string optional Custom icon for the card mdi:alert-circle Yes
title string optional Yes
subtitle string optional Yes
large boolean optional Large cards have a full-width container false Yes
font_color string optional CSS colorcode for the text Defined by theme Yes
icon_color string optional CSS colorcode or "auto" if you want it to change based on your entity state Defined by theme Yes
icon_size number optional Height of the icon (in pixels) Defined by HA (24px) Yes
background_color string optional CSS color for the background of the badge Defined by theme Yes
hide_condition string optional Javascript template that defines if card should be hidden false Yes
icon_animation string optional Possible values: 'spin' Yes

Examples

Basic card with static title, subtitle and custom icon

type: 'custom:button-text-card'
title: Title
subtitle: Subtitle
icon: 'mdi:lightbulb-outline'

Only title

type: 'custom:button-text-card'
title: Only title
icon: 'mdi:format-title'

Large card

type: 'custom:button-text-card'
title: Large version
subtitle: Ideal for important messages
icon: 'mdi:battery-high'
large: true

Custom background & font colors

type: 'custom:button-text-card'
title: Warning!
subtitle: Draw attention with custom colors
icon: 'mdi:comment-alert'
large: true
font_color: '#fff'
background_color: '#A81419'

Templating

For templating, we do NOT support Jinja2. Instead we opted to use Javascript as templating language (like button-card).

Templating is supported in most fields (see options for more details). Since these templates are executed in the front-end, there is no impact on the performance of your Home Assistant installation. It does, however, mean that you have to learn some Javascript.

Templates are enclosed by tripple brackets and can contain any valid Javascript: [[[ return "Hello from Javascript!" ]]]

Example: counting people home

type: 'custom:button-text-card'
icon: >
  [[[
    const count = Object.entries(states).filter(e => e[0].indexOf('person.') === 0 && e[1].state === "home").length;

    if(count === 0){
      return "mdi:home-export-outline";
    }else{
      return "mdi:home-import-outline";
    }
  ]]]
title: |
  [[[
    const count = Object.entries(states).filter(e => e[0].indexOf('person.') === 0 && e[1].state === "home").length;
    return "People home: " + count;
  ]]]
subtitle: Support for templating!

Conditional hiding

You can use a Javascript template to dynamically hide a card. This can be useful to create contextual cards (eg: only show when the front door is open, when there are lights on, ...).

To do so, write a Javascript template in the hide_condition attribute and return true if the card should be hidden.

Example: Only show card when music is playing

type: 'custom:button-text-card'
title: There is music playing
icon: 'mdi:music-circle'
hide_condition: |
  [[[
    const active_players = Object.entries(states).filter(e => e[0].indexOf('media_player.')===0 && e[1].state === 'playing');
    return active_players.length === 0;
  ]]]

Cool feature: when you go into edit mode, all hidden cards will appear with an opacity of 50%. That way you can easily manage all your cards.

Example: Only show card when the front door is open

type: 'custom:button-text-card'
large: true
entity: binary_sensor.voordeur
title: Front door open!
background_color: '#A81419'
font_color: '#fff'
icon: 'mdi:door-open'
hide_condition: |
  [[[ return entity.state === "off" ]]]

TODO

  • Document tap_action support

License & contributions

See LICENSE

Feel free to suggest improvements, flag issues, open pull requests, ...

More Repositories

1

SavjeeCoin

A simple blockchain in Javascript. For educational purposes only.
JavaScript
1,726
star
2

home-energy-monitor

ESP32-based Home Energy Monitor
TypeScript
219
star
3

savjeecoin-frontend

Angular app to visualize & interact with a blockchain
TypeScript
70
star
4

bearclaw

Menubar app to quickly create new notes in Bear
Objective-C
61
star
5

savjee.be

Source code of my Eleventy-powered website
HTML
43
star
6

yt-spam-classifier

Using TensorFlow to automatically filter crypto-related spam comments on YouTube.
Jupyter Notebook
39
star
7

google-sheets-wrapper

Lightweight wrapper around the official Google Sheets API that makes it easy to read/write rows
TypeScript
37
star
8

arduino-aws-iot-starter-template

Arduino code to connect ESP32 with AWS IOT (using MQTT and ArduinoJson)
C++
27
star
9

static-social-buttons

Static Social Buttons for Sharing and Tweeting
JavaScript
19
star
10

static-website-hosting-benchmark

17
star
11

trello-weekmenu-lambda

Meal planning with Trello and AWS Lambda
JavaScript
17
star
12

jsTixClock

A Tix Clock written in Javascript
11
star
13

php-backblaze-b2-uploader

PHP Class that allows you to upload files to Backblaze B2
PHP
11
star
14

svg2pdf

CLI tool to batch convert SVG files to PDF.
JavaScript
9
star
15

Xavier-s-Anagram-Solver

Anagram solver written in PHP.
PHP
8
star
16

3dmon

Simple 3D print progress monitor (for Home Assistant)
Python
6
star
17

OneHighlighter

CSS
6
star
18

eleventy-plugin-bibtex

Converts Bibtex references to APA notation in HTML
JavaScript
5
star
19

anagram-solver

Serverless anagram solver powered by Cloudflare Pages and R2
TypeScript
4
star
20

trash-pickup-belgium

Library to fetch trash pickups in Belgium (Ophaalkalender)
JavaScript
4
star
21

TwoFactorHelper

Safari Extension
Swift
3
star
22

trello-todo

Node.js script that moves Trello cards when they're almost due
JavaScript
3
star
23

xaviers-bitbar-plugins

My plugins for BitBar (written in node.js)
JavaScript
2
star
24

shell-scripts

Some shell-scripts I use
Shell
1
star
25

independent-zipper

Create independent zip archives of a given size
Python
1
star
26

arduino-pca9551

C++
1
star
27

energy-prices-api

TypeScript
1
star
28

dokuwiki-s3-backup

PHP script to backup a DokuWiki site to Amazon S3
PHP
1
star
29

docker-s3website-git-ftp-deploy

Dockerfile
1
star
30

dotfiles

JavaScript
1
star