It has been almost two weeks now since I started playing with Home Assistant. I thought I could figure it out myself digging through forum, logs and just playing through the interface but so far I failed this simple thing: setting up any automation to work.
When I check the state in the UI > Developer Tools > States it says it is on. I can trigger the automation myself and I can see it showing up in the Logbook. Here is the automation (created from the UI):
- id: '1579701262347'
alias: Log message when Mircea enters home
description: ''
trigger:
- entity_id: person.mircea_damian
event: enter
platform: zone
zone: zone.home
condition: []
action:
service: system_log.write
data_template:
level: info
message: '{{ now().time() }}'
For some reason the trigger does not work even though I can see in the Logbook when the person (myself) enters the house.
Iām starting to think that there is something more serious which is not probably working and frankly Iām lost now and could not find any clue where to look next, so please help!
Not 100% sure on this one as I use device tracker not person, but you seem to be mixing the two (two different entities on the same trigger, you would need a template to do that, but itās not needed) up on your trigger.
Try
(sort your spacing out, Iām on a phone)
trigger:
- platform: state
entity_id: person.mircea_damian
to: 'home'
How is your person set up? Does your person have gps coordinates? If the answer is no gps coordinates, then you have to use @Muttās trigger instead of the zone trigger. Zone triggers require gps devices.
Just a bit of extra explanation, triggers usually (there are exceptions but thatās a much longer story) work on āstatesā and how they convey their states is important and germane to the trigger you wish to create.
In the above trigger we are assuming that āpersonā works like a device tracker (device trackers report all sorts of usable information but the āstateā is reported as āhomeā (as set in the frontend) and ānot_homeā (note: it is NOT āawayā despite what you see in the frontend)) .
If you have zones defined, you may also see (say) āschoolā or āworkā etc.
If you wish to trigger an automation when you leave home the trigger qualification would be : -
from: āhomeā
(as in that was its previous state)
Right but if he wants to use zone triggers, he has to know why they arenāt working for him. Otherwise heāll just think they never work and therefore never use them. Iām simply explaining to him why it doesnāt work. Saying āthis is the only wayā without giving an explanation is poor support.
Petro is correct (get used to it it, he usually is )
In actual fact there are probably ā50 ways to leave your loverā (pun intended)
Find a way you feel comfortable with, but in 6 months time youāll come across another case where you need āsomething elseā, read the link posted by Petro itās all good background.
In fact you can search the docs first before posting questions, means that youāll often find what you need and if not youāll at least understand more of whatās involved in the solution.
Thank you for the quick feedback!
This is exactly how the UI automation editor has generated it.
So before I even thought what was dumped in the config I just accepted that this is the way it should be (basically UI would know better how to write that trigger than myself, a beginner with zero experience).
Indeed the person is not linked to a gps device (hence I see gps_accuracy: 0 in the attributes) it is rather linked to a device_tracker (using upc_connect):
Just went out and back in making sure that I lose the WiFi connection and the device tracker will see that.
The automation has worked as it can be seen in the Logbook:
So the generated config from the UI editor is mixing up two entities when creating such a trigger which is not working with non gps trackers.
So you have GPS coordinates. So the only reason itās not triggering is because you arenāt entering the zone via GPS. The gps coordinates need to cross the diameter set on your zone for it to trigger.
Depending on what you actually need from a device tracker you might want to look at the life360 integration. Itās good for people locations on the map, gives location feedback on defined zones and I use it for ādistanceā from home.
The Life360 app uses known WiFi ssid 's to minimise GPS updates (which uses more power) and other tricks to reduce drain. Itās pretty slick but you may not need it
Edit: the device tracker (as petro says) has co-ords but do you have remote access set up ? Or is it via an integration? Eg phone talks to trackerserver, ha talks to trackerserver ?
It is coming from the router. upc_connect is pulling the WiFi associations (with some frequency, do not know yet where to find that) and my mobile phone with that mac-address (8c_b9_4a_31_ec_ee) is seen as away or home.
I do not have any gps device (though that gave me an idea about integrating somehow my kidās watch which has a SIM and GPS).
Well, it seems like the UI is misleading then. At least you have a working automation now. Itās probably showing you the zone trigger because itās populated with GPS coordinates but it doesnāt know that the coordinates are āsimulatedā.
The check literally builds a radial distance between the 2 gps coordinates. If the distance is larger than the radius = not home. It does not check the perimeter, itās not a geofence.
The trigger occurs when the distance from home falls below the home radius. ie when you cross the perimeter.
This is not the distinction that HA assesses but that is the equivalent result. In fact given the definition of the āhome circleā the perimeter, is defined by that distance.
Technically āanyā movement within the home radius ācrosses a diameterā unless you only move radially.