I’m not sure if what I am doing is correct, but after many hours of Googling and reading examples I am somewhat stuck.
I have an API and when I type this API URL into a browser it returns me the following:
{"city":"london","date":"2020-04-21"}
I have added the following Sensor in my configuration.yaml file:
- platform: rest
resource: *URL*
method: GET
name: City_Date
When I add this to a sensor card in the lovelace UI, it brings back all the data.
What I then want to do do is split out the City and Date into individual sensors so it just returns “London” for the city and therefore I wrote the following Code.
This is a RESTful Sensor whose state will be the value of the “city” key (london) and with an attribute called date which contains the value of the “date” key (2020-04-21).
- platform: rest
resource: *URL*
method: GET
name: City
value_template: "{{value_json.city}}"
json_attributes:
- date