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.