Skip to content

Instantly share code, notes, and snippets.

@Bouni
Created September 6, 2019 10:39
Show Gist options
  • Select an option

  • Save Bouni/d53f23bf2c332097c799fd0b732d72bd to your computer and use it in GitHub Desktop.

Select an option

Save Bouni/d53f23bf2c332097c799fd0b732d72bd to your computer and use it in GitHub Desktop.
HA template sensor proposal
## Working example
- platform: template
sensors:
person_count:
friendly_name: "Number of Person at home"
unit_of_measurement: 'person'
entity_id:
- person.person1
- person.person2
- person.person3
- person.person4
value_template: >-
{{ states.person|selectattr('state', 'equalto', 'home')|list|length }}
## Not working example
- platform: template
sensors:
person_count:
friendly_name: "Number of Person at home"
unit_of_measurement: 'person'
entity_id: >-
{{ states.person | map(attribute='entity_id') | list }}
value_template: >-
{{ states.person|selectattr('state', 'equalto', 'home')|list|length }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment