mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-17 14:26:51 +00:00
Add documentation on new template functions for devices (#18540)
* Add documentation on new template functions for devices * fix examples * Update docs * rename function * rename back * Rename template function back
This commit is contained in:
parent
9d44781957
commit
e784059e83
@ -18,6 +18,15 @@ The following describes trigger data associated with all platforms.
|
||||
| `trigger.id` | Optional trigger `id`, or index of the trigger.
|
||||
| `trigger.idx` | Index of the trigger.
|
||||
|
||||
### Device
|
||||
|
||||
| Template variable | Data |
|
||||
| ---- | ---- |
|
||||
| `trigger.platform` | Hardcoded: `device`.
|
||||
| `trigger.event` | Event object that matched.
|
||||
| `trigger.event.event_type` | Event type.
|
||||
| `trigger.event.data` | Optional event data.
|
||||
|
||||
### Event
|
||||
|
||||
| Template variable | Data |
|
||||
|
@ -207,6 +207,31 @@ The same thing can also be expressed as a filter:
|
||||
|
||||
{% endraw %}
|
||||
|
||||
### Devices
|
||||
|
||||
- `device_entities(device_id)` returns a list of entities that are associated with a given device ID. Can also be used as a filter.
|
||||
- `device_attr(device_or_entity_id, attr_name)` returns the value of `attr_name` for the given device or entity ID. Not supported in [limited templates](#limited-templates).
|
||||
- `is_device_attr(device_or_entity_id, attr_name, attr_value)` returns whether the value of `attr_name` for the given device or entity ID matches `attr_value`. Not supported in [limited templates](#limited-templates).
|
||||
- `device_id(entity_id)` returns the device ID for a given entity ID. Can also be used as a filter
|
||||
|
||||
#### Devices examples
|
||||
|
||||
{% raw %}
|
||||
|
||||
```text
|
||||
{{ device_attr('deadbeefdeadbeefdeadbeefdeadbeef', 'manufacturer') }} # Sony
|
||||
```
|
||||
|
||||
```text
|
||||
{{ is_device_attr('deadbeefdeadbeefdeadbeefdeadbeef', 'manufacturer', 'Sony') }} # true
|
||||
```
|
||||
|
||||
```text
|
||||
{{ device_id('sensor.sony') }} # deadbeefdeadbeefdeadbeefdeadbeef
|
||||
```
|
||||
|
||||
{% endraw %}
|
||||
|
||||
### Time
|
||||
|
||||
`now()` and `utcnow()` are not supported in [limited templates](#limited-templates).
|
||||
|
Loading…
x
Reference in New Issue
Block a user