Group people

The home and away detection is enormously helpful. I’ve written things like “turn on the heat in morning, but only when I’m at home” and “turn off everything when I leave”. Now my daughter is coming to visit and I need “when anyone is at home” and “when everybody has left”. There are quite a few automations to amend. Is there a way to create a pseudoperson “anybody” and “nobody”? I looked through all setup und used search in the documentatioin but found nothing.
Danke

I use a template binary sensor as follows:

template:
  - binary_sensor:
      - name: "House Occupied"
        unique_id: house_occupied_0001
        state: >-
          {{ states('zone.home')|int > 0 
          or is_state('input_boolean.guest_mode', 'on') }}

For short-term guests you can manually toggle the Input boolean. For guests who are staying longer (but not long enough to need their own person entity) you can automate toggling the boolean however works for you whether it’s based on WiFi connection, webhook, etc.

1 Like

Thank you. I’ll try to understand that and perhaps rewrite it into a more primitive form. Guests who could be in while I’m out are not a concern right now, only named persons who can also access manual controls in a dashboard.
One more thing: How do I read that state in a condition?
Danke

The example above creates a Binary sensor entity with the ID binary_sensor.house_occupied. In a State condition you would just check if its state is ‘on’ or ‘off’:

condition:
  - alias: Test if any Person entities are home or the Guest Mode boolean is On.
    condition: state
    entity_id: binary_sensor.house_occupied
    state: 'on'
condition:
  - alias: Test if 0 Person entities are home and the Guest Mode boolean is Off.
    condition: state
    entity_id: binary_sensor.house_occupied
    state: 'off'

Thank you for your patience. One more thing: I Iooked around but could not find it. Where in settings do I define that binary sensor?
Danke

The configuration I posted is for a Template sensor which can be created 2 ways:

  1. Through the GUI in Settings > Device & Services > Helpers. Then click “Add Helper” and select “Template”. When using this method only the following should be pasted in the “state template” field:
{{ states('zone.home')|int > 0 or is_state('input_boolean.guest_mode', 'on') }}
  1. Added directly to your Configuration file

Thanks again. I can’t do that right now, seems I have first to learn how to update my HA inside Docker to the current version. Looking through my logfile, it seems not even necessary. There seems to be a predefined state “Home” that does just what I was trying to invent.

I have implemented it now just the way you have. The “superfluous” switch comes in handy, when I want to got to the cellar taking my smart phone with me without stopping all running automations. Also a binary sensor can be edited in one place without going to all the automations using occupancy. Thank you again, you were a great help.

1 Like

Drew, thank you again for your help. I have just improved on your solution to eliminate short glitches. Perhaps you too will find this helpful: