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

I think the problem is with timimg.
find out how often the proximity entity is updated.

When he changed the automation from looking at the states.proximity.home.state to looking at another known sensor, it worked, so I think it’s narrowed down to the template.

it is very very strange,
i did another test… on sensores.yaml
i created a template:

- platform: template
  sensors:
    aiai:
       value_template: "{{ states.proximity.home.state }}" 
       friendly_name: 'upa'

and value is ok…on dev-tools states… 42

but when i run this automation

trigger:
  - platform: numeric_state
    entity_id: sensor.aiai
    value_template: '{{ states.sensor.aiai.state }}'
    below: 100
action:
   service: homeassistant.turn_on
   entity_id: input_boolean.almosthome

the boollean.almoshome not change, LOL i am getting crazyyyy

@rpitera can you take a look at this for us please. I don’t know templates.

1 Like

I’m not a template expert, so take what I say with a grain of salt - in fact a shaker.

I’m wondering if you don’t need a float here:

{{ states.proximity.home.state | float }}

to make it a real number for numeric state instead of an integer?

SOLVED:
grrrrrr many hours and was so simple… i needed above and below.

- alias: 'test'
  trigger:
    platform: numeric_state
    entity_id: proximity.home
    above: 30
    below: 100
  action:
    service: homeassistant.turn_on
    entity_id: input_boolean.almosthome

if i put only below doesn´t work.

2 Likes

Doesn’t seem to work for me unfortunately:

- alias: 'Phone battery low'
  trigger:
    platform: numeric_state
    entity_id: sensor.battery
    above: 3
    below: 25
  condition:
    condition: state
    entity_id: device_tracker.xxxxxx
    state: 'home'
  action:
    - service: media_player.volume_set
      data:
        entity_id: media_player.home_group
        volume_level: '0.8'
    - service: tts.google_say
      entity_id: media_player.home_group
      data_template:
        message: 'Your phones batterylevel is at {{  states.sensor.battery.state }} percent. Dont forget to charge your phone.'

It looks like you have two spaces at the beginning of states.sensor.battery.state instead of one. Not sure if this is part of the issue.

That’s not the issue (I allways use two spaces when tenplating, I find it easier for the eyes ;)).
The DEV tool shows correctly:

'Your phones batterylevel is at 71 percent. Dont forget to charge your phone.'

And I can activate it manualy.

The problem is that it never triggeres somehow.

@rpitera ohw now I see the extra space.

Deleting one didn’t make any difference unfortunately.

OK, you didn’t say what your issue was.

Try taking out above: 3 and set the below: value to something like 99 for testing purposes and then leave the phone off the charger and see if it triggers.

I tried that earlier.
Sorry for being not clear, you’re right. Let me explain.

I used the method you suggested before without succes. This morning I read in this tread that adding the “above” part did the trick for Rodolfo. I tried that and still it’s not working for me. For testing purposes I changed the “below” status to 80. Since my batterylevel is at 71% right now that should trigger the automation but it;s not working.

I have all of my automations in a group card. This way I can trigger them manually very easily. It helps me figure out if the problem is the trigger or the conditions/actions.

If you trigger your automation manually, does it send the announcement?

@Bob_NL try this

in your configuration.yaml file

input_boolean:
  almosthome:
    name: 'working'
    initial: off



- alias: 'Phone battery low'
  trigger:
    platform: numeric_state
    entity_id: sensor.battery
    above:1
    below: 100
  condition:
    condition: state
    entity_id: device_tracker.xxxxxx
    state: 'home'
  action:
    service: homeassistant.turn_on
    entity_id: input_boolean.working

after changes that, restart your HA, then go to the devtools and verify if input.bollean.working changed from OFF to ON

Yes it does

ok now try this

- alias: 'Phone battery low'
  trigger:
    platform: numeric_state
    entity_id: sensor.battery
    above:1
    below: 100
  condition:
    condition: state
    entity_id: device_tracker.xxxxxx
    state: 'home'
  action:
    service: tts.google_say
    entity_id: media_player.home_group
    data_template:
      message: "Your phones batterylevel is at {{  states.sensor.battery.state }} percent. Dont forget to charge your phone."

@Rodolfo_Vieira It tried your suggestion with the boolean. Did not work.

I was thinking; the source of the sensor.battery is a httppost command sent every 15 minutes from my phone via Tasker. This means the sensor isn’t there on HASS restart at first (it takes max. 15 minutes for it to be there). Could it be that the automation isn’t initialized therefore (allthough there are also no errors in my logfile and the automation does show up in my frontend and can be activated manualy)?

ok, do you have a android phone right?
if yes… install the app called GPSlogger, this app is amazing, much better the owntracks, and give the possibilty to know your battery status each one minute.
i use it, do you want a try? if yes, i give you the configuration.

Thanks, installing right now :slight_smile:

Update: which one? there are several “GPS Logger” apps

gps logger author Mendhak

after instaled go to setting /logging details/ LOG TO CUSTOM URL and put

http://YOUR_DOMAIN_OR_IP/api/gpslogger?latitude=%LAT&longitude=%LON&battery=%BATT&device=NAME_YOUR_DEVICE&accuracy=%ACC&api_password=YOUR_PASS_API

3 Likes