Sensor Template: There’s Someone Inside Your House

Sometimes the GPS tracker on the mobile is not enough because can be “off” or can be used only on the mobile with the HA Companion App installed.

This sensor could be be a way to detect presence at home, mixing up existing and most common smart devices status like Switches, TV, WiFi connections, Motion sensors and Device trackers. Sensors to be included can be customized on your needs.

Simply collect all ON or HOME statuses and turn ON a dedicated binary sensor that could be used for any automation based on presence or not at home (start cleaning with your vacuum robot when away?).

Disclaimer: I don’t have any pet in my house…

I’m using following integrations and add-on:

  • Zigbee2Mqtt add-on for Sonoff Motion sensors
  • Fritz!Box integration for device trackers based on mobile connected to the router
  • Person integration based on my mobile GPS and HA companion app.

Sensor configuration

Assuming the Fritz!Box and Person Integration are already up-and-running, I’ve created two GROUPS containing all my Lights and Movement sensors:

  • Settings – Devices & Services
  • tab “Helpers” – button “+ CREATE HELPER” – “Group”
  • “Light Group”
  • Include all the Lights Entities you want to monitor
  • Click SUBMIT
  • Repeat the same step but this time choose “Binary sensor group” instead of “Light group”

Copy and Paste following code to you “Configuration.yaml” file and replace the entity names with your own:

  - binary_sensor:
      - name: "Home Presence Detected" # Determine if someone is at home based on device wifi connected, device gps, lights and movements
        state: >
             {{ is_state('device_tracker.mobile_john', 'home')
             or is_state('device_tracker.mobile_susan', 'home')
             or is_state('device_tracker.sm_a525f', 'home')
             or is_state('media_player.tv_lg_sala', 'on')
             or is_state('light.all_lights', 'on')
             or is_state('binary_sensor.all_movements_sensors', 'on')
        icon: mdi:home

Add the “Home Presence Detected” sensor to your Dashboard: