Send Door Codes With Home Assistant Zone Notifications

Get the garage or gym door code on the right phone as soon as it enters a Home Assistant zone.

Watch on YouTube ↗Get the code ↗Explore the gear →

Our gym has a door code, and so does a family member’s garage. I want the number handy by the time I’m standing at the keypad. So we send it a little early. When my phone enters the zone around the garage, Home Assistant sends me a push with that code. When Stacey heads to the gym, the gym code goes to her phone.

What’s the code? A phone shows the fake door code 4826.

Put the edge of the zone where the reminder will help

In Home Assistant, open Settings → Areas, labels & zones → Zones. Create a zone around the destination. We usually use a radius of about one mile, or roughly 1,600 meters. A smaller radius makes sense if you regularly pass close by without stopping. Your phone’s location update is what reports the crossing, so the exact spot can vary.

Make sure the Home Assistant Companion App on each participating phone can report background location and receive notifications. Associate its device tracker with the correct person in Home Assistant. Give the zone an easy name, like Gym.

Start with one zone and one phone

Here is the single-person version. Pick your person and zone for the trigger, then select the Companion App notification action for that person’s phone. The action name below is an example. Your installation supplies its own device name.

alias: Gym door code for Stacey
triggers:
  - trigger: zone.entered
    target:
      entity_id: person.stacey
    options:
      zone: zone.gym
actions:
  - action: notify.mobile_app_stacey
    data:
      title: "Gym code"
      message: !secret gym_code

Keep the digits out of the automation you share

In your local secrets.yaml, add a named value. This is a fake code for the example. Quote the digits so a code with a leading zero stays intact.

gym_code: "7315"

The !secret gym_code reference loads that value into the message. The phone still displays the digits. The secrets file stores plain text, so keep that file private. Our household version uses the same idea to initialize one text helper per place. Both people’s notification branches can then read the same helper.

Give the second person their own destination phone

Add a zone-entry trigger for the second person. Route each trigger to the phone of the person who crossed the boundary. Do the same for the garage with its own saved code. This way, if Stacey heads to the gym while I’m home, my phone stays quiet.

Test it with a dummy number. Send the notification action once to check the target phone, then enter the test zone from outside it to check the trigger. If the push works on its own, the automation trace and the person’s location history can tell you whether Home Assistant saw the crossing.

Here’s our full zone-entry automation. Home Assistant documents the zone settings and secrets syntax. For another use of arrival information, see the garage automations we use at home.

Watch the zone-entry example

Watch Home Assistant Sends Me the Door Code Before I Get There on YouTube

Advertisement

Keep building

The next useful idea, in your inbox.

Get new vCloudInfo posts by email.

Get new posts