Problem with proximity automation, i need your help [SOLVED]

@PhyberApex

Hello guys.
i´m having a problem with my automation.
I want to be notified when I’m less than 100 meters from my house, but is not working.

**device_trackers.yaml**
`- platform: gpslogger`

**zones.yaml**
    - name: Home
      latitude: 38.EDITED
      longitude: -9.EDITED
      radius: 5
      icon: mdi:home

**proximity.yaml**
home:
  ignored_zones:
    - notrabalho
  devices:
    - device_tracker.rodolfo
  tolerance: 200
  unit_of_measurement: m

**automation.yaml**
alias: "send message me when i am less 100 meters of my house"
trigger:
  - platform: numeric_state
    entity_id: proximity.home
    value_template: '{{ states.proximity.home.state | float }}'
    below: 100
condition: 
conditions:
  - condition: template
    value_template: '{{ states.proximity.home.attributes.dir_of_travel == "towards" and (states.proximity.home.state | float) <= 3 }}'
  - condition: state
    entity_id: group.all_devices
    state: 'not_home'
action:
  service: notify.fbrodolfo
  data:
    message: "isto e um teste"
    target: 
      - 351EDITED

I did a little test here in my house, to see if it worked.
I changed the coordinates of my house, as if I had less than 100 meters.
But I’m not notified.

on dir_of_travel: stationary says: stationary? What does it mean?
Am I doing something wrong?

Hey don’t know why you tagged me here but okay.
First of why are you doing this condition?

Secondly stationary means you are not moving right now…so neither away nor towords. Should include this in the template condition.

Third point. What are you trying to achieve with this:

This checks wether you are closer then 3 meters or not…which means your automation would only trigger if you are 3 meters away or closer…which probably is never the case because you would be “home” by then.

Also be adviced that the automation in it’s current state would trigger multiple times while going towards your home every time the state of the proximity updates you would get a notification.

~Cheers

Hi, I tagged you
Because you have always helped me,and I respect your knowledge very much. You said in another topic to feel free to question you. Sorry if I misunderstood.

As for this automation, I copied it from another topic, so now I’ve corrected it, I’m going to test today to see if it worked.

alias: "send message me when i am less 100 meters of my house"
trigger:
  - platform: numeric_state
    entity_id: proximity.home
    value_template: '{{ states.proximity.home.state | float }}'
    below: 100
condition: 
  - condition: template
    value_template: '{{ states.proximity.home.attributes.dir_of_travel == "towards" and (states.proximity.home.state | float) <= 100 }}'
action:
  service: notify.fbrodolfo
  data:
    message: "isto e um teste"
    target: 
      - 351EDITED

Don’t worry feel free to tag me anytime :slight_smile: I was just confused and thought maybe I promised to help with this or something…I don’t have the best memory sorry :smiley:

~Cheers

Well, I went to test to see if it worked.
but not. I went more than 100 meters from my house, then came walking towards my house, and I asked my wife to take a print screen of the computer.

The result was this:

17-03-03 20:40:22 INFO (Thread-11) [homeassistant.components.proximity] rodolfo: proximity calculation complete
17-03-03 20:40:22 DEBUG (Thread-6) [homeassistant.components.proximity] proximity.home update entity: distance=40: direction=towards: device=rodolfo
17-03-03 20:40:22 INFO (Thread-6) [homeassistant.components.proximity] rodolfo: proximity calculation complete

but i dont receive any notification…

You are already farther than I was. I did not read all the thread so forgive me if I am going over material you have already answered.

What are you using for location detection?
How often does it report to HA

The following is based on my understanding of proximity detection, GPS, etc. That could be completely wrong but I think i’m in the right general area on this.

Depending on how accurate the tool is, and how often it reports to HA, you will get varying results on the accuracy of your proximity. So if you were at 100m and the accuracy of your device is +/- 10 meters, you should get good results, if it’s +/- 50 meters, you won’t get as good of results. To some degree if you are using GPS, it will depend on how many satellites your phone or whatever can see. So if there are trees around, it won’t be as accurate as if it’s a wide open sky. Also, if it’s only taking a reading every 5 minutes, you may have been half way on your 100m walk when it took a reading and hadn’t taken another reading by the time you called your wife.

All of this is to say that the proximity number is probably a good measure when you are talking in terms of miles or KM, but probably not much good when it comes to meters or yards.

thank you for your answer.
I am using the gpslogger component, it updates the status every 1 minute, always right without fail, when you were writing the post for me I edited the previous post … I did another test and it appears “towards” but I did not receive it The notification. I do not understand why.

I’m one to simplify. Do you really need the “and” clause in this condition since the only way it is evaluated is if your trigger fires when you are less than 100m away?

Again in the interest of simplifying, instead of using the notification as the action, why not just make a input_boolean that you can toggle to see if your event is firing. Then if that works, we know the trigger is working, it’s the notify that’s having problems and we can focus on that.

Okay, I understand, so how do you suggest that you change all the action? You can give me an example, because I’ve never worked with bollean input, I need an example if you do not mind.

You can just set the state with the dev tools (navigation bar to the left on the bottom) dude no need to actually get out there :smiley:

~Cheers

in your configuration.yaml file

input_boolean:
  almosthome:
    name: 'Almost Home'
    initial: off

in your action

  action:
    service: homeassistant.turn_on
    entity_id: input_boolean.almosthome

like that:

alias: "send message me when i am less 100 meters of my house"
trigger:
  - platform: numeric_state
    entity_id: proximity.home
    below: 100
condition: 
  - condition: template
    value_template: '{{ states.proximity.home.attributes.dir_of_travel == "towards" }}'
action:
   service: homeassistant.turn_on
   entity_id: input_boolean.almosthome

???

I think so. I do most of my automations in AppDaemon now so my YAML is a little rusty, but that’s the idea. And define the input_boolean in your configuration.yaml file.

Ok, reboot the HA when it starts dir_of_travel is unknown, after a few minutes it updated towards, because I simulated that I have my house 30 meters from me … but input_bollean did not change to “almost home” :frowning:

@ReneTode can you take a look at the automation above. I’m over my head with templates. But I think there is something wrong in there. I just can’t describe what.

Sorry, not untill i am back at home next week.
i also must mention that i never were very succesfull with yaml automations.

thanks anyway

1 Like

any suggestion for someone else to ping?

@Bart274
i did another test…

alias: "send message me when i am less 100 meters of my house"
trigger:
  - platform: numeric_state
    entity_id: proximity.home
    value_template: '{{ states.proximity.home.state }}'
    below: 100
action:
   service: homeassistant.turn_on
   entity_id: input_boolean.almosthome

and boolean.almosthome not change …to " almost home"

after i did another test with the other entity of exanple:

    alias: "send message me when i am less 100 meters of my house"
    trigger:
      - platform: numeric_state
        entity_id: sensor.ram_free
        value_template: '{{ states.sensor.ram_free.state }}'
        below: 100
    action:
       service: homeassistant.turn_on
       entity_id: input_boolean.almosthome

and with this test works… the boolean change the name… off to “almost home”

i think it is the problem,…

looks that way, lets see if @ReneTode has any suggestions of who we can reach out to next. He’s a great source of information.

1 Like