Add template function: device_name (#38476)

This commit is contained in:
Paul Bottein 2025-04-14 14:30:10 +02:00 committed by GitHub
parent d368498f3d
commit 1a67539466
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -427,6 +427,7 @@ The same thing can also be expressed as a test:
- `device_attr(device_or_entity_id, attr_name)` returns the value of `attr_name` for the given device or entity ID. Can also be used as a filter. 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`. Can also be used as a test. Not supported in [limited templates](#limited-templates).
- `device_id(entity_id)` returns the device ID for a given entity ID or device name. Can also be used as a filter.
- `device_name(lookup_value)` returns the device name for a given device ID or entity ID. Can also be used as a filter.
#### Devices examples
@ -444,6 +445,11 @@ The same thing can also be expressed as a test:
{{ device_id('sensor.sony') }} # deadbeefdeadbeefdeadbeefdeadbeef
```
```text
{{ device_name('deadbeefdeadbeefdeadbeefdeadbeef') }} # Sony speaker
{{ device_name('sensor.sony') }} # Sony speaker
```
{% endraw %}
### Config entries