Skip to content

Add template function: device_name #38476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions source/_docs/configuration/templating.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down