I’ve looked at the bayesian sensor but it’s not exactly what I need.
I have a person entity and its device tracker, which is updated both by a Fritz component (when connects to local network) and from the iOS app through GPS.
I want the person’s location to be mapped to the Home zone IF AND ONLY IF the Fritz component sees the device inside the network (i.e.: device tracker’s state = “home” AND attribute source_type = “router”)
I want the person’s location to be mapped to the Work zone IF the iOS location tracking says so (i.e.: device tracker’s state = “work”, attribute source_type will be “gps” for sure)
well I managed to write a Template Sensor whose behaviour is the one described:
sensor:
- platform: template
sensors:
vins_location:
friendly_name: "Vin's Location"
value_template: >-
{% if is_state('device_tracker.vins_iphone', 'home') and is_state_attr('device_tracker.vins_iphone', 'source_type', 'router')%}
Home
{% elif is_state('device_tracker.vins_iphone', 'Work') %}
Work
{% else %}
Outside
{% endif %}
How do I connect the state of this sensor to the state of the Person entity? As far as I can see, I can only map that to a device_tracker entity. How do I make Home Assistant treat it like a device_tracker entity?
I don’t want the “home” condition to be triggered by the GPS, because it will be triggered even if I’m 50 m away from the building, but not inside the apartment. I want the “home” condition to be triggered only by the local network connection (by the Fritzbox). At the same time, I want the GPS to trigger other zones (work, etc.).
As I wrote, I’ve managed to implement the behaviour I want in that custom template sensor. What I need is therefore to link the output of this template sensor to the Person state.
Is this possible? Otherwise I’ll need to use directly this sensor as the trigger of all location-based automations and leaving the Person state unused, but I thought linking it to the Person state would be a cleaner and more elegant solution.
The mqtt device tracker is ready-to-use component, and you can just create an automation that sets that state.
I used to have a setup similar. I had 2 device trackers tied to a “person” (before the person option existed in HA). One GPS and one WiFi. In Node Red, if EITHER of those went from not home to home, it updated an input boolean (actually I used an mqtt switch so I could use it with other systems), to say I was “home”. If BOTH devices went from “home” to “not home”, it would mark my switch as “not home”.
When the person integration came out it didn’t do what I wanted but now I am content with how it works, but it is configured opposite of what you are looking for.