Skip to content

Instantly share code, notes, and snippets.

@jlpouffier
Created August 5, 2023 20:41
Show Gist options
  • Save jlpouffier/44a6a5937eed0881a71c09c0dff56894 to your computer and use it in GitHub Desktop.
Save jlpouffier/44a6a5937eed0881a71c09c0dff56894 to your computer and use it in GitHub Desktop.
Home Assistant Hot Tip of the Day: Home Occupancy Sensor
# https://www.home-assistant.io/integrations/template/
template:
- binary_sensor:
- name: home_occupied
unique_id: home_occupied
state: "{{states('zone.home')|int > 0}}"
device_class: occupancy
attributes:
is_home_full: "{{states('zone.home')|int == expand(states.person)|list|count}}"
present_persons: |
{{
expand(states.person)
| selectattr('state', 'eq', 'home')
| map(attribute='attributes.friendly_name')
| list
| sort
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment