Using the results of a simple GPS Rest call?

If you use your original setup with the automation I posted, it will work for both google and gps

In my case, it’s a cat :slight_smile: so I know where he is :slight_smile:

I tried copy pasting your automation but keep getting

Message malformed: extra keys not allowed @ data[‘condition’][0][‘value_tempate’]

The way I tried it is to create a new empty automation from the UI and then paste. Then I have to change it a bit as the yaml there is different then the one you pasted. Also tried to just copy your automation in automation.yaml, but also that gives errors. I am very unfamiliar with this so not sure what to change.

@petro
the command sometimes gives

`"log": "OUT 2021-12-06 14:17:12",`

or

`"log": "IN 2021-12-06 14:17:12",`

i’m interested in the words IN or OUT in that json, that means if the device is ON or OFF

how can i create the value template so it creates the word on/off ?

    - name: GPS365_Online
      value_template: "{{ (value[1:] | from_json)[0].log.split(' ')[0:1] }}"

that already gives me : ['OUT']

check it against the word out then using ==

like this?

    - name: GPS365_Online
      #value_template: "{{ (value[1:] | from_json)[0].log.split(' ')[0:1] }}"
      value_template: >
        {% (value[1:] | from_json)[0].log.split(' ')[0:1]  == ['OUT'] %}
          off
        {% else %}
          on
        {% endif %}

gives me template syntax error :’

crap, forgot the if word

you’re missing if, and you added brackets around out.

1 Like

@petro
that automation you posted earier; for you its working?

it gives errors for me:

- alias: GPS365_Pepe
  initial_state: 'on'
  mode: parallel
  trigger:
  - platform: state
    entity_id:
    - sensor.gps365_google
    - sensor.gps365_gps
  variables:
    coords: >
      {{ trigger.to_state.state.split(',') | list if trigger is not none and trigger.to_state is defined else none }}
  condition:
  - condition: template
    value_tempate: "{{ coords | length == 2 }}"
  action:
  - service: device_tracker.see
    data:
      dev_id: "{{ trigger.to_state.entity_id.replace('.','_') }}"
      gps: "{{ coords }}"

2021-12-06 16:12:24 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: [value_tempate] is an invalid option for [automation]. Check: automation->condition->0->value_tempate. (See /config/configuration.yaml, line 100).

are you using it?

I’m not, I made the automation on the fly. But value_tempate just has a spelling error, should be value_template

omg , thnx

i really need to read

I put the typo it in :man_shrugging:. not your fault

1 Like

still struggling with that “out” word

value_template: "{{ (value[1:] | from_json)[0].log.split(' ')[0:1] }}"

gives me in sensor : [‘OUT’]

but below are not correct

      value_template: >
        {% if (value[1:] | from_json)[0].log.split(' ')[0:1]  == 'OUT' %}
          off
        {% else %}
          on
        {% endif %}

or

      value_template: >
        {% if (value[1:] | from_json)[0].log.split(' ')[0:1]  == "OUT" %}
          off
        {% else %}
          on
        {% endif %}

or

      value_template: >
        {% if (value[1:] | from_json)[0].log.split(' ')[0:1]  == OUT %}
          off
        {% else %}
          on
        {% endif %}

it should give me “off” , but gives me “on” instead

i think its because of the lines:

value_template: "{{ (value[1:] | from_json)[0].log.split(' ')[0:1] }}"

gives me in editor :

image

I just noticed you’re slicing too, just take the first item.

(value[1:] | from_json)[0].log.split(' ')[0] == 'OUT'

that was it

thnx again!

@petro, you helped me a while ago with these sensors below

But since i have enabled rest in my config, i have slowdown/timeouts… i think its because of the rest:

2021-12-28 16:35:58 WARNING (MainThread) [homeassistant.setup] Setup of rest is taking over 10 seconds.

On the info, i see the startup for rest takes sometimes 20 seconds…

Am i right, that below configuration, there are 7 sensors, so is the resource is excuted 7 times? Or just once?
I use google assistant a lot, and sometimes when i turn on a light, it takes a while, maybe its because the rest are commands are fired at that time and some timeout is occuring?

rest:
  - resource: !secret gps365_get_status_resource-
    scan_interval: 60
    sensor:
    - name: GPS365_Google
      value_template: "{{ (value[1:] | from_json)[0].google }}"
    - name: Gps365_LAT
      value_template: "{{ (value[1:] | from_json)[0].gps.split(',')[5] }}"
    - name: Gps365_LON
      value_template: "{{ (value[1:] | from_json)[0].gps.split(',')[6] }}"      
    - name: GPS365_Battery
      value_template: "{{ (value[1:] | from_json)[0].bat }}"
    - name: GPS365_Update
      value_template: "{{ (value[1:] | from_json)[0].sec }}"
    - name: GPS365_On_off
      value_template: >
        {% if (value[1:] | from_json)[0].log.split(' ')[0] == 'OUT' %}
          off
        {% else %}
          on
        {% endif %}

Guys, anyone using the 365gps ? since a week when running command below, i always get:

EDIT:

Found it, this “&ver=4.10” needs now to be added to the string …

thanks for the question and the answer! :slight_smile: didnt realize yet that it stopped working.
How did you figure out that you needed to add “&ver=4.10” to it?

I use “fiddler” to capture the http(s) please proxy traffic from the android APK app, there you can see the traffic what the app does…
That’s how I figured out all other commands like remote turn on/off , change interval time …

Verry cool app, also usefull for other apps to integrtate commands in HA

1 Like