Hi!
I’ve spent the last 3 hours trying to figure out what’s the problem with my rest sensor, but I’m unable to solve it. Maybe someone can help me out.
I’m trying to get the temperature in a nearby beach. This is the json that I’m getting from the data provider:
{"name": "temp", "beautyName": "Sea surface temperature", "lat,lon": ["39.472", "2.532"], "values": 27.38160514831543, "units": ["Celsius", "\u00baC"], "localtime": "2021/9/12 20:4"}
This is the configuration for my REST sensor:
- platform: rest
name: Playa El Mago (Temperatura)
resource_template: http://seaboard.ws.socib.es/temp/{{ now().year }}/{{ now().day }}/{{ now().month }}/{{ now().hour }}/{{ now().minute }}/39.472/2.532/
method: GET
json_attributes:
- name
- values
- lat,lon
- localtime
value_template: "{{ value_json['values'] | float }}"
device_class: temperature
unit_of_measurement: "°C"
But the value returned by the sensor is always NaN:
At first I thought that the problem was the use of the “values” keyword, that’s why I used the brackets notation instead of the dots notation.
However, If I try this in the developers tools tab:
{% set value_json = {"name": "temp", "beautyName": "Sea surface temperature", "lat,lon": ["39.472", "2.532"], "values": 27.38160514831543, "units": ["Celsius", "\u00baC"], "localtime": "2021/9/12 20:4"} %}
{{ value_json['values'] | float }}
It works OK:
Hope someone can help me. Thank you in advance.