Skip to content

Commit

Permalink
feat: provide value inside value_template
Browse files Browse the repository at this point in the history
  • Loading branch information
denysdovhan committed Apr 21, 2022
1 parent 0a431d3 commit ad5ae4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ stats:
- attribute: motor_speed
unit: RPM
subtitle: Motor Speed
- value_template: >-
{{ (states('sensor.purifier_filter_life') | float(0) / 3600) | round(1) }}
- entity_id: sensor.purifier_filter_life
value_template: '{{ (value | float(0) / 3600) | round(1) }}'
unit: hours
subtitle: Filter Life
shortcuts:
Expand Down Expand Up @@ -130,13 +130,13 @@ Here is what every option means:

You can use any attribute of purifier or even any entity by `entity_id` to display by stats section:

| Name | Type | Default | Description |
| ---------------- | :------: | -------- | ---------------------------------------------------- |
| `entity_id` | `string` | Optional | An entity_id with state, i.e. `sensor.purifier_aqi`. |
| `attribute` | `string` | Optional | Attribute name of the stat, i.e. `filter_left`. |
| `value_template` | `string` | Optional | Jinja2 template returning a value. |
| `unit` | `string` | Optional | Unit of measure, i.e. `hours`. |
| `subtitle` | `string` | Optional | Friendly name of the stat, i.e. `Filter`. |
| Name | Type | Default | Description |
| ---------------- | :------: | -------- | ---------------------------------------------------------------------------------------------------- |
| `entity_id` | `string` | Optional | An entity_id with state, i.e. `sensor.purifier_aqi`. |
| `attribute` | `string` | Optional | Attribute name of the stat, i.e. `filter_left`. |
| `value_template` | `string` | Optional | Jinja2 template returning a value. `value` variable represents the `entity_id` or `attribute` state. |
| `unit` | `string` | Optional | Unit of measure, i.e. `hours`. |
| `subtitle` | `string` | Optional | Friendly name of the stat, i.e. `Filter`. |

### `shortcuts` object

Expand Down
1 change: 1 addition & 0 deletions src/purifier-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ class PurifierCard extends LitElement {
hass=${this.hass}
template=${value_template}
value=${state}
variables=${{ value: state }}
></ha-template>
`;

Expand Down

0 comments on commit ad5ae4f

Please sign in to comment.