I use UniFi for device tracking with wifi on my phone and my wife’s (I also use the HA phone app in tandem). So both of these trigger the status of our person entities.
I want a basic guest person entity that I can toggle via an input boolean, but I can’t seem to get this to work. I don’t have a known_devices.yaml file, as I have nothing that uses it (I tried creating one manually with a guest device tracker, but it doesn’t seem to do anything).
I thought I could manually change a device tracker status with an automation, but this automation is failing somewhere and I can’t quite pinpoint it.
Has anyone else had success with something similar?
Here’s the YAML I am using for my automation:
alias: a_manage_guest_device_tracker
description: 'Update guest device tracker'
trigger:
- platform: state
entity_id: input_boolean.guest_presence
condition: []
action:
- service: device_tracker.see
data:
dev_id: guest
location_name: |-
{% if is_state('input_boolean.guest_presence', 'on') -%}
home
{%- else -%}
not_home
{%- endif %}
mode: single
I just manually created a known_devices.yaml and threw this in there, but it’s obviously not working… is there something I can do to actually get a device tracker that I can update via the automation above?
This automation works for me, with no device_tracker.y’all file.
alias: Person, from apple homekit
description: ''
trigger:
- platform: state
entity_id: input_boolean.virtual_person_home_alexander
from: 'off'
to: 'on'
action:
- service: device_tracker.see
data:
dev_id: alexandertracker
location_name: home
mode: single
Your automation looks the same, just using a template, so strange it is not working. Might be something with template generations a string or?
I have 2 automations, one for on and one for off
Where is your dev_id coming from if not a device_tracker.yaml file? How did you create the device_tracker to update? I think that’s where my main issue is, it doesn’t appear to be an issue with the automation itself.
I set up a similar automation as @khvej8 this weekend and had the same questions about how the entity was to be initially created. Turns out it was automatically created when the automation ran, and it created the known_devices file as well.
Based on that, I’d look at the templates. My automation uses trigger ids and a condition in the action to set the home/not_home states.
They are not to be defined, the service device_tracker.see will create it. Just made a new one called devicetrackertest1 using developertools through the gui. remember everything in small letters.
Only use “Device ID” and “Location name”, where device name is the entity name (this does not exists, just put in the name you want) and location name is “home” or “not_home”
Cool, I often forget about the developer tools. I tested it out and it worked fine. This helped me think to check my automations, and they weren’t getting created for some reason… turns out the yaml was correct so HA wasn’t throwing any errors, but the formatting was different from my other automations, so it wasn’t registering them… so odd. Anyway, I got it working with your example. Thanks so much!