My automations do not trigger

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!

Here some screenshots:

  1. When the automation is being triggered manually:

  2. When the person is entering home but the trigger is not firing:
    38

Iā€™m seeing quite some errors in the Developer Tools > LOGS but they do not seem related.

Any hints?

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'
1 Like

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)

Event zone leaving and arriving events are valid triggers, like he has, but they require gps devices.

Acknowledged and agreed but letā€™s keep it simple as this is his first automation and heā€™s trying to get is head round something that will work.

Edit and I think that the above will cover 90% of most peopleā€™s usage???

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.

1 Like

Petro is correct (get used to it it, he usually is :rofl: )

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.

Hi @Mutt & @petro

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):

device_tracker:
  - platform: upc_connect
    password: XXXXXX
    host: 192.168.NN.NN

Here is the person:

I have just updated my config manually with @Muttā€™s suggestion and I will try to see if it works.

Thank you

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:

Annotation 2020-01-22 152841

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.

Okay, please feedback on what you find.

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 ?

My guess is that GPS coordinates are being inherited from ā€œhomeā€. Because I have set the location of it on the map.

Is device_tracker.8c_b9_4a_31_ec_ee coming from your router or is it an actual gps device? If itā€™s a router device, then you are correct.

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ā€™.

Sorry, but itā€™s perimeter :smiley:

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.

Ah yes, then you understand.

It does not build a perimeter, like a geofence. So a diametrical check is correct.