#were am i going wrong with this

1 messages · Page 1 of 1 (latest)

unique grove
#
sensor:
  rest:
    resource_template : https://api.open-meteo.com/v1/meteofrance?latitude={{ state_attr('device_tracker.ioniq_5_location', 'latitude') }}&longitude={{ state_attr('device_tracker.ioniq_5_location', 'longitude') }}&current=temperature_2m&timezone=auto
    scan_interval: 900
    sensor:
      - name: "outsidetemp_ioniq5"
        value_template: "{{ value_json['current']['temperature_2m'] }}"
        unit_of_measurement: "°C"
#

i get response of UndefinedError: 'value_json' is undefined

unique grove
#

tried this instead too and no cigar

#
    scan_interval: 900
    sensor:
      - name: temp_outside_ioniq5"
        value_template: "{{ value_json['current'] }}"
        unit_of_measurement: "°C"```
harsh nimbus
#

Why have you made a sensor key under the rest key? Should just be name and value_template

#

Like the examples on the rest integration page

sensor:
  - platform: rest
    resource: http://ip.jsontest.com
    name: External IP
    value_template: "{{ value_json.ip }}"
unique grove
#

I am basically just trying to pull temp from cars location were ever it is.

#

ill try that

#

was basing it of this sensor that does not work for my location

#
  - resource_template : https://api.open-meteo.com/v1/meteofrance?latitude={{ state_attr('device_tracker.ev6_location', 'latitude') }}&longitude={{ state_attr('device_tracker.ev6_location', 'longitude') }}&current=temperature_2m&timezone=auto
    scan_interval: 900
    sensor:
      - name: "meteofrance_kia_ev6"
        value_template: "{{ value_json['current']['temperature_2m'] }}"
        unit_of_measurement: "°C"```
velvet jolt
#

Not sure if this is your only problem, but you have a space between resource_template and the colon (:)

unique grove
#

I just want the sensor to add the temprature from location of the car.

harsh nimbus
#

OK well first thing you should do is pull out that resource template into developer tools template editor and double check it's returning the right url

velvet jolt
#

Looks like you’ve posted templates for both, actually. Which one are you really using?

unique grove
#

pirate weather as meteo does not support my location

#

the meteo one is a working sample from someone else i was trying to replicate

unique grove
harsh nimbus
#

Not the whole thing, just the resource_template

unique grove
#

platform: rest
resource: https://api.open-meteo.com/v1/meteofrance?latitude={{ state_attr('device_tracker.ioniq_5_location', 'latitude') }}&longitude={{ state_attr('device_tracker.ioniq_5_location', 'longitude') }}&current=temperature_2m&wind_speed_unit=mph&timezone=GMT
scan_interval: 900
name: outsidetemp_ioniq5
value_template: "{{ value_json['current']['temperature_2m'] }}"

harsh nimbus
#

No

#

Just put everything after "resource_template:" from your non-working example into the template editor

unique grove
#

same thing value_json undefined

#

the template without the value template tells me it watching for changes to location

#

but the moment I add the value template to try to get it to get temprature from resource it has a hissy fit.

harsh nimbus
#

Yeah. Like I said... 5 times now you should only put the resource template in there. Everything else is meaningless at this point

#

Now take that constructed url from the template editor and put it in your browser

unique grove
#

yes that gives me the values, but I want them values to create a template sensor

#

to pull the temprature in based on this

harsh nimbus
#

What does the url give you in your browser

unique grove
#

{"latitude":51.32,"longitude":0.87999964,"generationtime_ms":0.012993812561035156,"utc_offset_seconds":0,"timezone":"GMT","timezone_abbreviation":"GMT","elevation":12.0,"current_units":{"time":"iso8601","interval":"seconds","temperature_2m":"°C"},"current":{"time":"2024-12-13T09:00","interval":900,"temperature_2m":4.0}}

harsh nimbus
#

OK that's good, it's returning something sensible at least

#

So the next thing I would do is making sure you are using the right keys. I see no option to have sensor as a key in a rest sensor

#

You just define name, value_template etc at the same level as resource_template

proven ridgeBOT
unique grove
#

I got it working by adapting conditions to pirate weather, but a lot more code