Atreiiide
(Atreiiide)
December 18, 2022, 5:32pm
1
Hello everybody !
I would like to have a sensor to know which doors are opened. This way I will be able to query it using API and send information by SMS
I created a group with all my doors sensors (all_doors_windows).
I tried this but this is not working. sensor.doors_status is not showing which doors are opened. :
configuration.yaml
- platform: template
sensors:
doors_status:
entity_id:
- sensor.doors_status
friendly_name: "door_status"
value_template: "{% set open_windows = ( states | selectattr('entity_id', 'in', state_attr('group.all_doors_windows','entity_id')) | selectattr('state','in',['on','open']) | list | map(attribute='name')| join(', ') ) %} {{open_windows }}"
When I enter the value template in development tools, it’s working :
Thanks for your help !
You have an extraneous
entity_id:
- sensor.doors_status
in your sensor configuration… You can also simplify the template a bit.
- platform: template
sensors:
doors_status:
friendly_name: "door_status"
value_template: >
{% set doors = state_attr('group.all_doors_windows', 'entity_id') %}
{{ expand(doors) | selectattr('state','in',['on', 'open'])
| list | map(attribute='name') | join(', ') | default('All Closed', 1) }}
Atreiiide
(Atreiiide)
December 18, 2022, 8:58pm
3
Thanks. I tried and it works.
I was expecting a value (like “door garage”) in the status of the sensor :
But I requested sensor using API and I have the information (which doors are opened). Do you know why the sensor status is not showing anything ?
“Status” is not the same as “State”… If you want to see the state of the sensor use the States tool in the Developer Tools menu or click the entity name in the Entities menu then select the “Info” tab.
The “not editable” symbol seen in the status of the Entities menu reflects the fact that you did not assign a unique_id
to your sensor. If you want to be able to use the Entities menu to edit the sensor’s info you need to assign one.
1 Like
Atreiiide
(Atreiiide)
December 19, 2022, 8:37am
5
Understood thanks for your help !