Add is_number test (#21110)

This commit is contained in:
Petro31 2022-01-10 07:01:52 -05:00 committed by GitHub
parent 1d9a3f41f2
commit 26a1714b1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -208,6 +208,28 @@ The same thing can also be expressed as a filter:
{% endraw %}
{% raw %}
```text
{% for energy in expand('group.energy_sensors') if is_number(energy.state) %}
{{ energy.state }}
{%- if not loop.last %}, {% endif -%}
{% endfor %}
```
{% endraw %}
The same thing can also be expressed as a test:
{% raw %}
```text
{{ expand('group.energy_sensors')
| selectattr("state", 'is_number') | join(', ') }}
```
{% 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.