for an auto-entities card I need something like the template below, so I can replace the fixed state: '>30'
I had originally to an input_numbers state:
{{states('input_number.power_threshold')}}
{% set threshold = states('input_number.power_threshold') %}
{{states.sensor
|selectattr('entity_id', 'search', '_actueel')
|selectattr('state','>',threshold)
|map(attribute='state')
|list}}
results in
because state is a string, and the number is a number obviously…
I can not use |map(‘float’,0) anywhere, so how do I fix this comparison to be correct…
- type: custom:auto-entities
card:
type: entities
card_mod: &mod
style: |
ha-card {
box-shadow: none;
margin: 0px -16px 0px -16px;
}
filter:
template: >
{{states.sensor
|selectattr('entity_id', 'search', '_actueel')
|selectattr('state','>',states('input_number.power_threshold'))
|map(attribute='entity_id')
|list}}
# include:
# - entity_id: sensor.*_actueel
# state: '>30'
please have a look? thanks!
__ edit__
Wait, as always Order of Operations… !
If I change the order of operations to:
{{states('input_number.power_threshold')}}
{% set threshold = states('input_number.power_threshold')|float %}
{{states.sensor
|selectattr('entity_id', 'search', '_actueel')|map(attribute='state')
|map('float',default=0)
|select('>',threshold)
|list}}
so this selects the correct entities, but now I need to map those back to their entity_id…
{% set threshold = states('input_number.power_threshold')|float %}
{{states.sensor
|selectattr('entity_id', 'search', '_actueel')|map(attribute='state')
|map('float',default=0)
|select('>',threshold)
|map(attribute='entity_id')
|list}}
wont do this,