Skip to content

Commit

Permalink
Merge pull request #26 from megakid/patch-1
Browse files Browse the repository at this point in the history
Support showing entity attribute values
  • Loading branch information
iantrich authored Dec 17, 2021
2 parents 2fc6da2 + b9137c1 commit fee532a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ A simple card to display big numbers for sensors. It also supports severity leve
| title | string | optional | Name to display on card
| scale | string | 50px | Base scale for card: '50px'
| entity | string | **Required** | `sensor.my_temperature`
| attribute | string | optional | the entity attribute you want to display e.g. `current_temperature`. The entity state will be shown if not defined.
| min | number | optional | Minimum value. If specified you get bar display
| max | number | optional | Maximum value. Must be specified if you added min
| color | string | `var(--primary-text-color)` | Default font color. Can be either hex or HA variable. Example: 'var(--secondary-text-color)'
Expand Down
4 changes: 3 additions & 1 deletion bignumber-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ class BigNumberCard extends HTMLElement {
set hass(hass) {
const config = this._config;
const root = this.shadowRoot;
const entityState = hass.states[config.entity].state;
const entityState = config.attribute
? hass.states[config.entity].attributes[config.attribute]
: hass.states[config.entity].state;
const measurement = hass.states[config.entity].attributes.unit_of_measurement || "";

if (entityState !== this._entityState) {
Expand Down

0 comments on commit fee532a

Please sign in to comment.