How to extract temperature and humidity of each place from the following json API to the sensor data in Home assistant?
https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=rhrread&lang=en
How to extract temperature and humidity of each place from the following json API to the sensor data in Home assistant?
https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=rhrread&lang=en
With restful sensors:
e.g.
rest:
- resource: https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=rhrread&lang=en
sensor:
- name: "King's Park Temperature"
value_template: "{{ value_json['temperature']['data'][0]['value'] }}"
- name: "Hong Kong Observatory Temperature"
value_template: "{{ value_json['temperature']['data'][1]['value'] }}"
You can use this tool to find other paths to the data you want:
Just copy the raw data (use the “Raw Data” button on your resource page) to the left column and drill down on the right column. The path is at the top of the right hand window. Replace “x” with “value_json”. Also wherever you see the key “value” you have to use square bracket notation for this as “value” has a special meaning in the template.
That is a useful tool to find the json data. Thank you very much!