Value_template User error? Please help

@petro The second sensor isn’t being created and I’m not seeing any errors in the logs in regards to it.

rest:
  - authentication: basic
    scan_interval: 3600
    resource: "http://localhost/vip.php?apiKey=ahhhhhh&cmd=req_extended_status"
    sensor:
      - name: "Ram Pickup"
        value_template: "{{ value_json.results.device.deviceStatus.ignitionOn }}"
        json_attributes_path: "$.results.device.deviceStatus"
        json_attributes:
          - "doorsLocked"
          - "doorsOpen"
          - "remoteStarterActive"
          - "securitySystemTriggered"
          - "securitySystemArmed"
          - "dtcCodePresent"
      - name: "Ram Tracker"
        json_attributes_path: "$.results.device"
        json_attributes: 
          - "latitude"
          - "longitude"

everything looks good, did you restart?

I did…still not showing… :thinking:

Are you looking for the correct entity_id?

Yep… it should be sensor.ram_tracker. Tried filtering by “sensor.”, “ram”, “tracker”. Nothing there.

try adding a value_template, maybe that’s required. I haven’t looked at the docs

Might be what it is. I got an error restarting this time before adding the value template.

I was going to add it after getting up so I could test the value template for it being home in the dev console…lol.

“homeassistant.exceptions.InvalidStateError: Invalid state encountered for entity ID: sensor.ram_tracker. State max length is 255 characters.”

just set the value_template to ‘OK’

That was the trick. I just put the $.results.device.address there. You are an amazing help. If you get paid you deserve a raise. :rofl: :rofl: :stuck_out_tongue_closed_eyes:

Sorry to keep spamming you. So the rest sensors are the first set of code below. I also created a binary_sensor for the GPS tracker as below. Is that necessary as I see the Ram Location showing up on the map? I won’t be using it for automations or anything as I’m only doing hour scan interval. I just want access to it on the map. The binary sensor I created has the lat/long in the attributes but the state is on/off instead of home/not_home. I like something that has the home/not_home setup for a lovelace card but I could keep value_template to the address and get an idea where it is. :man_shrugging:

rest:
  - authentication: basic
    scan_interval: 3600
    resource: "http://localhost/vip.php?apiKey=ahhhhhhh&cmd=req_extended_status"
    sensor:
      - name: "Ram Pickup"
        value_template: "{{ value_json.results.device.deviceStatus.ignitionOn }}"
        json_attributes_path: "$.results.device.deviceStatus"
        json_attributes:
          - "doorsLocked"
          - "doorsOpen"
          - "remoteStarterActive"
          - "securitySystemTriggered"
          - "securitySystemArmed"
          - "dtcCodePresent"
      - name: "Ram Location"
        value_template: "OK"
        json_attributes_path: "$.results.device"
        json_attributes: 
          - "latitude"
          - "longitude"
template:
  - binary_sensor:
      - name: Ram Tracker
        device_class: presence
        state: >
          {{ states('binary_sensor.ram_tracker') }}
        attributes:
          latitude: >
            {{ state_attr('sensor.ram_location' , "latitude") }}  
          longitude: >
            {{ state_attr('sensor.ram_location' , "longitude") }}

Maybe?

{{ 'Home' if states('binary_sensor.ram_tracker') == "off" else 'Not Home' }}

you want the state of it being inside your zone. I.e. if it’s inside your zone it would be on because it’s home.

The binary sensor says off for some reason…so I assumed off was Home…

The rest sensor with the lat/long shows inside my zone but shows on the map…I thought any trackers that were inside the home zone didn’t show on the map?

oh you’re referecing itself. You can’t do that. You have to actually determine if the truck is home or not.

Ohhhhhhhhh :thinking: :thinking: :thinking:

Now to figure out the state template for this device being home or not home. I guess that zone.home is a good starting place…?

Yeah I’m lost ugh. I do see there really is no template for presence sensor…

If you can’t come up with a home/away state, just make it a sensor instead of binary sensor with the state OK. Then attach it to a person entity named your truck and it will then do home/away for it. But tbh, you said earlier that you could only connect to the truck locally. So there’s really no point in home/away. Whenever the sensor is available, it’s home.

No the server is just a local php file. All that php file is, is really a token getter and a receiver for the json data. I can connect to my home assistant and my truck away from home. Sorry if I was misunderstood.

Then go the person route.

That’s what I’m looking at, now.

all you have to do is make a person and attach Ram Location to it. It’s like 4 clicks in the UI, nothing else.