mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-12 20:06:52 +00:00
Support variables, icon, and picture for all template platforms (#39634)
Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
parent
6b32853f6a
commit
0a1d25d370
@ -181,11 +181,13 @@ template:
|
|||||||
- binary_sensor:
|
- binary_sensor:
|
||||||
# Common configuration options
|
# Common configuration options
|
||||||
- unique_id: my_unique_sensor_id
|
- unique_id: my_unique_sensor_id
|
||||||
availability: "{{ 'sensor.watts' | has_value }}"
|
variables:
|
||||||
icon: "{{ 'mdi:flash-alert' if states('sensor.watts') | float > 100 else 'mdi:flash' }}"
|
my_entity: sensor.watts
|
||||||
name: "{{ states('sensor.watts') }} Alert"
|
availability: "{{ my_entity | has_value }}"
|
||||||
|
icon: "{{ 'mdi:flash-alert' if states(my_entity) | float > 100 else 'mdi:flash' }}"
|
||||||
|
name: "{{ states(my_entity) }} Alert"
|
||||||
# Entity specific configuration options
|
# Entity specific configuration options
|
||||||
state: "{{ states('sensor.watts') | float > 100}}"
|
state: "{{ states(my_entity) | float > 100}}"
|
||||||
device_class: problem
|
device_class: problem
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -213,6 +215,15 @@ template:
|
|||||||
description: An ID that uniquely identifies this entity. Will be combined with the unique ID of the configuration block if available. This allows changing the `name`, `icon` and `entity_id` from the web interface.
|
description: An ID that uniquely identifies this entity. Will be combined with the unique ID of the configuration block if available. This allows changing the `name`, `icon` and `entity_id` from the web interface.
|
||||||
required: false
|
required: false
|
||||||
type: string
|
type: string
|
||||||
|
variables:
|
||||||
|
description: Key-value pairs of variable definitions which can be referenced and used in the templates below (for trigger-based entities only). Mostly used by blueprints. With State-based template entities, variables are only resolved when the configuration is loaded or reloaded. Trigger based template entities resolve variables between triggers and actions.
|
||||||
|
required: false
|
||||||
|
type: map
|
||||||
|
keys:
|
||||||
|
"variable_name: value":
|
||||||
|
description: The variable name and corresponding value.
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
{% endconfiguration %}
|
{% endconfiguration %}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user