schford
(Stuart)
October 5, 2024, 9:51am
1
Could anyone help me with excluding my drive gates from the open count please?
{{ states.binary_sensor
|select('search', 'door|window')
|map(attribute='entity_id')
|select('is_state', 'on')
|reject('is_hidden_entity')
|reject('in', [' binary_sensor.drive_gate'])
|list |count }}
does this do what you want?
{{ states.binary_sensor
|rejectattr('entity_id', 'eq', 'binary_sensor.drive_gate')
|select('search', 'door|window')
|map(attribute='entity_id')
|select('is_state', 'on')
|reject('is_hidden_entity')
|list |count }}
1 Like
schford
(Stuart)
October 6, 2024, 3:50pm
3
thanks so simple when you see it!
1 Like
schford
(Stuart)
October 8, 2024, 7:34am
4
For anyone interested / searching in the future I have tidied my code up a little, it now shows how many open windows and doors there are whilst excluding the drive gate and not double counting any groups of windows (which need to be tagged with the label Group)
{{ states.binary_sensor
| rejectattr('entity_id', 'eq', 'binary_sensor.drive_gate')
| rejectattr('entity_id', 'in', label_entities('Group'))
| selectattr('attributes.device_class', 'defined')
| selectattr('attributes.device_class', 'search', 'door|window')
| selectattr('state', 'eq', 'on')
| list | count }}