Calendar-Based Presence Detection for Kids in Home Assistant

Lately, I’ve been working on some fun Home Assistant automations based on whether my kids are in the house. The challenge? My kids don’t have cell phones, so traditional presence detection won’t work. So instead, I hacked together a solution using Google Calendar events and day-of-week logic.

With this setup, I can do things like:

  • Get a notification if the TV turns on when it shouldn’t be
  • Turn off the lights in the kids’ rooms automatically when they’re at school

But since my kids don’t have cell phones, presence detection is trickier than normal, so I’ve had to mimic it using Google Calendar events and simple logic surrounding the days of the week.

This is pretty easy to do by creating an input_boolean helper entity (Settings → Devices & Services → Helpers → Create Helper → Toggle) and a corresponding automation to update it:

alias: Update Kids In House Status
description: Updates kids' presence in house based on criteria
triggers:
  - minutes: /5
    trigger: time_pattern
  - entity_id: calendar.google_calendar_personal
    trigger: state
  - event: start
    trigger: homeassistant
conditions: []
actions:
  - target:
      entity_id: calendar.google_calendar_personal
    data:
      start_date_time: "{{ today_at('00:00') }}"
      end_date_time: "{{ today_at('23:59') }}"
    response_variable: todays_events
    action: calendar.get_events
  - variables:
      event_summaries: >-
        {{ todays_events['calendar.google_calendar_personal'].events |
        map(attribute='summary') | list }}
      has_grandma: "{{ 'Kids with Grandma' in event_summaries }}"
      has_no_school: "{{ 'No School' in event_summaries }}"
      current_hour: "{{ now().hour }}"
      is_saturday: "{{ now().weekday() == 5 }}"
      is_sunday: "{{ now().weekday() == 6 }}"
      school_day: >-
        {{ (not is_saturday and not is_sunday) and current_hour >= 8 and current_hour <
        15 }}
      kids_away: "{{ has_grandma or (school_day and not has_no_school) }}"
  - if:
      - condition: template
        value_template: "{{ kids_away }}"
    then:
      - target:
          entity_id: input_boolean.kids_in_house
        action: input_boolean.turn_off
    else:
      - target:
          entity_id: input_boolean.kids_in_house
        action: input_boolean.turn_on
mode: single

The automation checks every 5 minutes whether specific calendar events exist (“Kids with Grandma” or “No School”), combines that with school hours (8am-3pm on weekdays), and flips the input_boolean accordingly. When the kids are away—either at school during normal hours or with grandma per the calendar—the boolean turns off. Otherwise, it stays on.

Leave a Reply

Your email address will not be published. Required fields are marked *