Set input.boolean when last person leave house

Hello.
I would like to turn on my alarm and turn on an “anti-theft” light theme when the last person in the household leaves the house.
Any suggestions?

1 Like

How do you track people?

With OwnTracks, network router and iCloud

We have multiple device trackers for each individual assigned to each person, and a “family” group containing all persons.
When group.family is “not_home” then there is no-one in the house.

@TazUk: Could you please post a copy of your configuration file?

Something like @TazUk proposed, or alternatively i use this:

binary_sensor:
# someone at home?
  people_home:
    value_template: >-
      {{ is_state('device_tracker.google_maps_123', 'home')
         or is_state('device_tracker.1_wifi', 'home') # these are ping sensors
         or is_state('device_tracker.2_wifi', 'home')
         or is_state('device_tracker.3_wifi', 'home')
         or is_state('device_tracker.google_maps_345', 'home')
         or is_state('device_tracker.google_maps_234', 'home') }}

Then use an automation to switch your boolean after 10 minutes that every1’s gone:

automation:
  - alias: Mark house as empty
    trigger:
    - platform: state
      entity_id: binary_sensor.people_home
      to: 'off'
      for:
        minutes: 10
    action:
    - service: input_boolean.turn_on
      data:
        entity_id: input_boolean.home_empty

2 Likes

@krash: Thanks! That looks good. I will try to integrate that into my own config.

I added device trackers to Persons created through the front end (I’m trying to use the front end where possible), under Configuration > Persons.

I have my configuration files broken out, so in my configuration.yaml I reference the groups.yaml:

group: !include groups.yaml

And in groups.yaml I created the family group (names redacted):

# group for security automations, hidden
family:
  name: Family
  view: no
  entities:
    - person.tazuk
    - person.tazuk_so

Example automation using group.family:

- id: camera_blink_arm_auto
  alias: 'Arm Blink Cameras'
  hide_entity: True
  trigger:
    - platform: state
      entity_id: group.family
      from: 'home'
      to: 'not_home'
      for:
        minutes: 10
  condition:
    - condition: state
      entity_id: alarm_control_panel.home_alarm
      state: 'disarmed'
  action:
    - service: alarm_control_panel.alarm_arm_away
      data:
         entity_id: "alarm_control_panel.blink_sync"
    - delay: '00:00:{{ (range(45, 60)|random|int) }}'
    - service: alarm_control_panel.alarm_arm_away
      data:
         entity_id: "alarm_control_panel.blink_outdoor"
1 Like

Thanks, @TazUK. I’ve been inspired by your code, and I got it figured out.