Estimated reading time: 9 minutes

Are you curious about how you can effectively track people and activities in your home? With Home Assistant, you have a powerful tool at your fingertips to help you do just that. Whether you just want to know when the kids get home from school or you want to make sure you've been to the gym long enough to reach your goals, Home Assistant offers you a wide range of possibilities. Let's discover together how you can track people and activities with Home Assistant!

For detailed instructions and an explanation of all configuration options, I recommend the YouTube video linked below. In this video, every single setting is explained in detail so that you receive comprehensive instructions for the exact setup. You can find any code from the video in this article so that you can use it directly without having to type it in.

What is Home Assistant?

Home Assistant is an open source platform for home automation that aims to connect and centrally control all devices in the home. It is designed to provide a unified user interface and simple, flexible control for a variety of smart home devices from different ecosystems. Here are some points in favor of Home Assistant:

  1. CompatibilityHome Assistant supports thousands of devices and services from various manufacturers, including lighting, air conditioning, heating, cameras, weather sensors, voice assistants and more.
  2. Local controlUnlike many commercial smart home platforms that rely on cloud services, Home Assistant runs locally on your network. This means increased privacy and reliability, as your smart home devices work even without an active internet connection.
  3. Automation and scenesOne of the main features of Home Assistant is the ability to create complex automations and scenarios. For example, you can have lights switch on automatically when it gets dark or turn on the heating when the temperature falls below a certain level.
  4. Simple user interfaceHome Assistant offers a user-friendly interface that makes it easy to monitor and control devices. This interface is fully customizable.
  5. Integration with voice assistantsHome Assistant can be integrated with voice assistants such as Amazon Alexa or Google Assistant to enable voice-controlled control of your smart home devices.
  6. Open source and community-drivenSince Home Assistant is open source, it is supported by an active community that is constantly developing new integrations and improving existing ones.
  7. Data protection and securityAs a locally running platform, Home Assistant has the advantage that the data remains within its own network. This protects privacy and increases security compared to cloud-based solutions.

In summary, Home Assistant is a powerful and flexible solution for those who want to design their own smart home and control their devices centrally, regardless of the manufacturer or ecosystem.

Requirements

To track people and activities, you need compatible devices. Here are some examples:

  • Smartphones: With the Home Assistant Companion app, you can track the location data of you and your family members in real time.
  • Motion sensorsThese devices help you to monitor activities in different rooms.
  • Door and window sensors: So you know when someone enters or leaves the house.
  • ZonesZones in combination with your smartphone's location data mean you know exactly when you were and at what time.

Furnishings

With Home Assistant, you can turn your home into an intelligent environment. Here I show you in chronological order how to track people and activities effectively. Just follow these steps.

1. set up people and install the app

Before you can get started, you need to set up the people in Home Assistant. The following steps are necessary for this:

  1. Create personal profilesGo to the settings in Home Assistant and select "People". Create a profile for each person you want to track. Don't forget to add photos to make the profiles clearer.
  2. Install the Home Assistant appInstall the Home Assistant Companion app on people's smartphones. The app is available for both iOS and Android.
  3. Store devices as device trackersOpen the app and log in with your Home Assistant account. The app will now add the smartphone as a device tracker. In Home Assistant, you can see and configure the device under "Settings" > "Integrations" > "Mobile App".

2. add helpers

The next step is to add a helper in the GUI. In this case, we create a input_boolean for each person to track whether they are at home.

  1. Add helperGo to "Settings", select "Helpers" and click on "Add helper".
  2. Create input BooleanSelect "Toggle" (switch) and name it appropriately, for example input_boolean.sascha_is_at_home.
  3. Function of the input BooleanThis switch indicates whether the person is at home or not. It is used in automations to check various statuses and trigger actions.

3. add sensors in the configuration.yaml

Now you have to configuration.yaml Edit file to add two sensors per person. These sensors track the time the person is at home or away.

  1. Open file: Open the configuration.yaml file in a text editor.
  2. Add sensorsAdd the following code per person:
- platform: history_stats
  name: Sascha - Time at home
  entity_id: person.sascha
  state: "home"
  type: time
  start: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
  end: "{{ now() }}"

- platform: history_stats
  name: Sascha - time in absence
  entity_id: input_boolean.sascha_is_at_home
  state: "off"
  type: time
  start: "{{ now().replace(hour=0, minute=0, second=0, microsecond=0) }}"
  end: "{{ now() }}"

Explanation of the code

  • Sascha - Time at home:
    • platform: history_stats: The platform that tracks historical statistics.
    • name: The name of the sensor.
    • entity_id: The entity that is being tracked (here the person Sascha).
    • state: The state that is being tracked (here "home").
    • type: The type of sensor (here "time").
    • start and endThe period over which the time is measured (here from midnight to now).
  • Sascha - Time in absentia:
    • entity_id: The entity that is being tracked (here the input Boolean).
    • stateThe state that is being tracked (here "off").

4. restart

To apply the changes, you must restart Home Assistant:

  1. Perform restartGo to "Settings" > "Server control" and click on "Restart".
  2. CheckAfter the restart, the new sensors should be available and you can start tracking people's activities.

5. create automation

alias: Tech. Monitor - Presence
description: >-
  Testing by notify.smartphones: message: The entity {{ trigger.entity_id }}
  has changed. Required for automations.
trigger:
  - platform: state
    entity_id:
      - person.sascha
    to: null
action:
  - if:
      - condition: template
        value_template: "{{ trigger.entity_id == 'person.sascha' }}"
    then:
      - choose:
          - conditions:
              - condition: state
                entity_id: person.cptdaydreamer
                state: home
            sequence:
              - service: input_boolean.turn_on
                data: {}
                target:
                  entity_id: input_boolean.sascha_is_at_home
          - conditions:
              - condition: state
                entity_id: person.cptdaydreamer
                state: not_home
            sequence:
              - service: input_boolean.turn_off
                data: {}
                target:
                  entity_id: input_boolean.sascha_is_at_home
    alias: Sascha

Overview

This automation tracks the presence of Sascha and updates a input_booleanto indicate whether Sascha is at home or not. In addition, a notification is sent to smartphones when the status of the entity changes.

Alias and description

The automation has the name "Tech. Monitor - Presence". The description explains that a notification is sent to smartphones when the status of the monitored entity changes.

Trigger

The automation is triggered by a change of state of the entity person.sascha is triggered. This means that the automation starts as soon as the status of this entity changes.

Actions

The automation first checks whether the change of state is actually caused by person.sascha was triggered. This ensures that the subsequent actions are only executed if the change originates from this specific person.

Conditional actions

There are two main actions that depend on conditions:

  1. When person.sascha is at home, the input_boolean.sascha_is_at_home is switched on. This indicates that Sascha is at home.
  2. When person.sascha is not at home, the input_boolean.sascha_is_at_home is switched off. This indicates that Sascha is not at home.

Application in a dashboard

This code creates a clear dashboard in Home Assistant that displays various data and sensors for a person called Sascha.

type: entities
entities:
  - type: section
  - entity: sensor.sascha_time_in_absence
    type: custom:multiple-entity-row
    name: Presence
    state_header: Absent
    secondary_info: Last 24 hours
    entities:
      - entity: sensor.sascha_time_at_home
        name: At home
  - type: section
  - entity: sensor.sm_g990b_battery_level
    type: custom:multiple-entity-row
    name: Phone status
    state_header: Battery
    entities:
      - entity: sensor.sm_g990b_detected_activity
        name: Activity
      - entity: sensor.sm_g990b_steps_sensor
        name: Steps
  - type: section
  - entity: sensor.sm_g990b_geocoded_location
    type: custom:multiple-entity-row
    name: Location
    styles:
      text-align: right
  - type: section
  - type: custom:vertical-stack-in-card
    cards:
      - type: history-graph
        entities:
          - entity: person.sascha
            name: presence
            title: Sascha
        hours_to_show: 24
        refresh_interval: 0
        card_mod:
          style: |
            ha-card {
              margin: -10px -10px 6px;
            }

The code also gives you the option of reading out other sensors on your smartphone, such as your pedometer or current activity. The more sensors you enable in the Home Assistant app on your smartphone, the more data you can add to your dashboard.

YouTube video implementation

https://youtu.be/-Cf7GTA9oak

Conclusion

With Home Assistant, you can efficiently track people and activities in your home. By setting up people profiles and installing the Home Assistant Companion App on your family members' smartphones, you get real-time location data. You can monitor your children's attendance when they come home from school and make sure you reach your fitness goals by tracking your time at the gym.

Devices and sensors

Use compatible devices such as motion sensors, door and window sensors to monitor activity in different rooms and know when someone enters or leaves the house. By combining zones with the location data from your smartphones, you can see exactly who has been where and when.

Simple setup

Setup is simple and takes just a few steps:

  1. Set up people and install the appCreate person profiles in Home Assistant and install the Companion app on the smartphones. These then act as device trackers.
  2. Add helper: In the GUI, add a input_boolean for each person to track whether they are at home or not.
  3. Configure sensors: Edit the configuration.yamlto add sensors that track the time of presence and absence. Then restart Home Assistant to apply the changes.

Dashboard customization

Create a clear dashboard that displays various data and sensors. Customized map types allow you to:

  • Display attendance and absence times.
  • Monitor the phone status, such as the battery level and detected activities.
  • Visualize the current location.
  • View history graphs to track attendance over the last 24 hours.

Versatile application

The more sensors you enable in the Home Assistant app on your smartphone, the more comprehensive the data on your dashboard becomes. For example, you can add the pedometer or current activity to get even more detailed insights.

Your intelligent home

With Home Assistant, you can make your home smarter and safer. You can keep track of the activities and presence of your family members and use the system's versatile options to customize your automations. This means you are always in control and can design your home to suit your needs.

The display of the products was implemented with the affiliate-toolkit plugin.

0 Comments

Leave a Reply

Avatar placeholder

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

en_US