WTH can't I create a dummy guest tracker that can be switched with an input boolean

I would love to create a dummy device tracker that can be set to home or not home based on an input boolean so I can easily use it in my automations for when a guest mode is required

Just create an input_boolean…

image

2 Likes

I have done but it would be easier if the input boolean could switch a dummy device tracker home or not_home so I can include it in my existing device tracker groups instead of a separate condition in my automation’s.

You could create an input_select and have the options of home, not_home to select from…

Look at Device_tracker.see . You can change the state of a device tracker manually with this

4 Likes

Example of using device_tracker.see to create a device tracker from a input_boolean.

input_boolean:
  person_homekit_home:
    name: "Person HomeKit Home"
    icon: mdi:home-map-marker

automation:
  - alias: "Device Tracker - Home Assistant Start create Homekit Device Tracker"
    trigger:
      - platform: homeassistant
        event: start
    action:
      - delay: '00:01:00'
      - service: device_tracker.see
        data_template:
          dev_id: person_homekit
          host_name: "Person HomeKit"
          location_name: >-
            {% if is_state('binary_sensor.person_homekit_home', 'on') -%}
              home
            {%- else -%}
              not_home
            {%- endif %}

  - alias: "Device Tracker - Update Homekit Device Tracker"
    trigger:
      - platform: state
        entity_id: binary_sensor.person_homekit_home
    action:
      - service: device_tracker.see
        data_template:
          dev_id: person_homekit
          host_name: "Person HomeKit"
          location_name: >-
            {% if is_state('binary_sensor.person_homekit_home', 'on') -%}
              home
            {%- else -%}
              not_home
            {%- endif %}

There is another WTH post on this where I suggested a device_tracker template.

3 Likes

You could use a mqtt devicer tracker and a template switch for that.

Thank you I managed to use this & it works great!

Glad I could help, it took me about an hour to figure it out one day after I stumbled across the device_tracker.see service. It was not clear to me initially how powerful it could be.

I currently have a input_boolean exposed to HomeKit and setup a HK automation to turn on/off when I leave/arrive home. So far its been pretty solid.

Why would anyone need to convert a input_boolean to a person entity using device_tracker.see?

I currently set automations based on my input_boolean.away_mode. Adding another automation to change the status of a person entity maybe another point of failure for me. Just want to increase my understanding to determine if I need or would be beneficial for me to do it also.

Not sure what you are asking. :slight_smile:

Maybe this will help…

The automations that I posted are based off input_boolean toggled by Homekit. One automation is to create the device tracker at HA start, because they are not persistent, and the other is to update the device tracker when then input_boolean changes. Both those automations use the device_tracker.see service.

Then the device tracker can be assigned to a person, I have a few associated with my “person”.

Finally the people (persons) are in a group so that all my automations, scripts, etc… use the group to determine if people are home. This way I can add and remove people from the group and do not have to update it everywhere.

Thanks.

I guess the question I am asking is, why don’t you just based your automations, scripts, etc around the input_boolean rather than creating a device tracker through device_tracker.see which is having use other automations to turn/off based on the state of the input_boolean. Is it so it appears visually as a person in Lovelace and when linked to your HA account on the frontend? Or another reason I am neglecting to think about?

Just interested as all my automations are based on the state of my input_boolean.away_mode exposed to HomeKit. I have not created a device tracker / person entity based on the state of this boolean.

Ah, good question!

The reason I choose to do it this way is to bring more than one device tracker into determining if a person (usually me) is home. While HomeKit is pretty accurate, there are times where it is not and this was not acceptable for my use cases (unlocking the front door on arrival). So I wanted to use multiple device trackers, by having the HomeKit input boolean drive a device tracker, then that device tracker can be attached to a person. And then the person state will be determined by multiple device trackers. I have HomeKit, Owntrack and iOS App device trackers that consolidate under the context of a person.

This consolidation of device trackers has proven to be more accurate than just using one device tracker. There are factors, urban area with odd cell tower placement (my phone will someones report I’m 1/4 mile ways from home when I’m home because it switched to another tower), etc… Not everyone needs to employee this strategy, but I hope this helps those who are having issues.

I might be incorrect but it seems the device is persistent now. You may not need the start up Automation

As of what version?

2021.1.1

Anyone able to test?

Tried exactly this code. But I always get the error message that it must contain a dev_id or mac.

How is this working in your Home Assistant?

Can you post the relevant yaml from your system and the full text of the error you are seeing?

What I posted does need modifications to work with your configuration.