I'm lost... How to manually toggle person state home/away

Hi,

I have been looking everywhere, but maybe not good enough. For a simple way to temporarily override my automations, I want to have a switch on the Lovelace UI to toggle my guest “person” home or away.

Seems simple, but I can’t seem to find anything useful.

Is there anyone who knows how to do this?

Presence detection does not have any manual triggers to change state.

You could extend into a separate boolean and automate toggling it with other devices. There are some ideas in this thread

1 Like

Hi Paul, thanks for the quick response. Is device_tracker.see not an option anymore?

I don’t know how to use that though. Can I make a fake device tracker and change the state trough the Lovelace interface?

I saw the page you mentioned earlier and it looks like a really complex solution for a seemingly simple problem.

1 Like

Oh wow. I didn’t know about that service! I may have to make use of this.

The device_tracker.see service will need a valid device dev_id to change state. As far as I know, there are no “fake devices”.

I’ve got it working! :slight_smile: It might be a little rough around the edges, but it works.

Step 1:

Go to your known_devices.yaml and create a new “fake” device tracker. Just copy one of your other ones for the format and create a new one with a unique MAC adress.

Step 2:

Make a new card in Lovelace, like this one: (with your own tracker details of course)

- type: entity-button
        tap_action:
          action: call-service
          service: device_tracker.see
          service_data:
            dev_id: guest_presence
            location_name: 'not_home'
        hold_action:
          action: call-service
          service: device_tracker.see
          service_data:
            dev_id: guest_presence
            location_name: 'home'
        show_icon: true
        show_name: true
        entity: person.gast 

This will create a button you can operate with a press and hold to change the state to home and with a click to change it to not_home.

2 Likes

Careful with known_devices.yaml—it’s been deprecated and may disappear in a future update: https://www.home-assistant.io/integrations/device_tracker/#known_devicesyaml

Hmm… Thats not good… So no solution after all. At least, probably not in the future.

Back to the drawing board.

Wat do I want? A cheap form of presence detection for my guests. Options are:

  1. Manually (Like my current solution)

  2. With a keychain of some sort. (I don’t want to use my guests phone)

Did you find a good solution for this? I would also like to have a simple toggle to set my home to “home” or “away” mode. It’s very common in other apps / systems like SmartThings. The way our home operates its best to have a simple manual toggle for most of our use cases for now.

1 Like

I’m also very interested in a solution for this. I tried making a toggle system with input booleans and templating, but I can’t get it to work properly: Automation for person home/not_home toggle in lovelace

Some kind of simple manual toggle should be possible, right?

Device trackers and input booleans are different. However, you can make one that will control the other.

Also, for those concerned about the lack of known_devices.yaml, there’s no need to create a fake device tracker anymore. When you call the service device_tracker.see, it will create the device tracker if it isn’t there. Here’s my solution for a Guest boolean and device tracker:

alias: Guest device tracker
description: ''
trigger:
  - platform: state
    entity_id: input_boolean.guest
condition: []
action:
  - service: device_tracker.see
    data:
      dev_id: guest
      location_name: |-
        {% if is_state('input_boolean.guest', 'on') -%}
          home
        {%- else -%}
          not_home
        {%- endif %}
mode: single

Then, I created a user (that can’t log in) called Guest, assigned device_tracker.guest to it, and created a group with myself and guest:

group:
  someone_home:
    name: Someone home
    entities:
      - person.brent
      - person.guest

Now group.someone_home is a single source of whether myself or a guest is at my house.

13 Likes

Since I use my own presence detection (by using a BLE scanner coupled with BLE beacon in our cars, over MQTT, with customized FW to handle changing UUIDs for security), I just force the person state into whatever I need by using an external Python script. There are several out there, something like that:

The yaml then looks like this:

service: python_script.set_state
data_template:
  entity_id: person.alex
  state: not_home

This is probably going to fail in horrible ways if you combine it with an actual HA device tracker. But since I don’t use any, it works like a charm for me.

1 Like

Hi, I copied that solution but device_tracker.see still creates a known_devices.yaml where the track parameter of the created deveice I have to set to true. After restart, the entity is available.
Is that right? And what happens, if the known_devices file is depricated one time?