How to read accuweather data?

Hello everyone.
I need your help to improve the accuweather integration.

I have two questions :

  1. how to write the query

There are a lot of data that can be found in the Accuweather API (current, forecasts, …).

I use the restful integration to get data using a query with json-attributes which works well when the data are well structured and named.

However, i don’t find how to read them when the data are not named.
There is a topic here https://community.home-assistant.io/t/json-attributes-with-no-parent-key/53650 but I don’t find how to structure the query.

Here is the sensor (last version, but I have tried many other options)

  - platform: rest
    name: 'Accuweather_prevision'
    resource_template: "http://dataservice.accuweather.com/forecasts/v1/hourly/12hour/133609?apikey={{states('input_text.accuweather_key')}}&language=fr-fr&details=true&metric=true"
    json_attributes: 
      - [0]
#      - [1]
    value_template: '{{ value_json[0].DateTime }}' 
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json
  - platform: template
    sensors:
      accuweather_h_hour:
        friendly_name: H hour
        value_template: "{{ value_json[0].EpochDateTime | timestamp_custom('%H:%M', false)}}"

and here the output of the query (I have simplified the data, you have only the data for the first hour )

[
{
"DateTime": "2020-08-26T15:00:00+02:00",
"EpochDateTime": 1598446800,
"WeatherIcon": 4,
"IconPhrase": "Passages nuageux",
"HasPrecipitation": false,
"IsDaylight": true,
"Temperature": {
"Value": 22.8,
"Unit": "C",
"UnitType": 17
},
"RealFeelTemperature": {
"Value": 22.8,
"Unit": "C",
"UnitType": 17
},
"WetBulbTemperature": {
"Value": 15,
"Unit": "C",
"UnitType": 17
},
"DewPoint": {
"Value": 9.4,
"Unit": "C",
"UnitType": 17
},
"Wind": {
"Speed": {
"Value": 20.9,
"Unit": "km/h",
"UnitType": 7
},
"Direction": {
"Degrees": 260,
"Localized": "O",
"English": "W"
}
},
"WindGust": {
"Speed": {
"Value": 24.1,
"Unit": "km/h",
"UnitType": 7
},
"Direction": {
"Degrees": 260,
"Localized": "O",
"English": "W"
}
},
"RelativeHumidity": 43,
"IndoorRelativeHumidity": 43,
"Visibility": {
"Value": 16.1,
"Unit": "km",
"UnitType": 6
},
"Ceiling": {
"Value": 9754,
"Unit": "m",
"UnitType": 5
},
"UVIndex": 4,
"UVIndexText": "Modéré",
"PrecipitationProbability": 0,
"RainProbability": 0,
"SnowProbability": 0,
"IceProbability": 0,
"TotalLiquid": {
"Value": 0,
"Unit": "mm",
"UnitType": 3
},
"Rain": {
"Value": 0,
"Unit": "mm",
"UnitType": 3
},
"Snow": {
"Value": 0,
"Unit": "cm",
"UnitType": 4
},
"Ice": {
"Value": 0,
"Unit": "mm",
"UnitType": 3
},
"CloudCover": 64,
"MobileLink": "http://m.accuweather.com/fr/fr/boulogne-billancourt/133609/hourly-weather-forecast/133609?day=1&hbhhour=15&unit=c",
"Link": "http://www.accuweather.com/fr/fr/boulogne-billancourt/133609/hourly-weather-forecast/133609?day=1&hbhhour=15&unit=c"
},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{}
]

I know how to read the data in the JSon table (test done with developer/template) and it works well.

If you know how to write the restful query I will be very happy !!!

  1. query frequency

When you define two sensors (one for restful integration and one for the data you want to read), do you know if HA send two queries to accuweather or only one (the first with restful) ?

When is this query send to accuweather ?
the first time upon initialisation. and after ?
each time you update the sensor ?
is there a scan_interval defined in the restful integration ? (how to find it ?)
If yes how to stop the scan by HAssio ? scan_interval = 0 ? = -1 ?

I’m asking this because my accuweather developer account has been blocked because I have sent too many queries and I am sure I have not issued more than 50 queries per day (which is the maximum number allowed with a trial account)

I want to stop the automatic queries to accuweather and use a timer automation for that!

Thanks for your help !

[
{
"DateTime": "2020-08-26T15:00:00+02:00",
"EpochDateTime": 1598446800,
"WeatherIcon": 4,
"IconPhrase": "Passages nuageux",
"HasPrecipitation": false,
"IsDaylight": true,
"Temperature": {
"Value": 22.8,
"Unit": "C",
"UnitType": 17
},
"RealFeelTemperature": {
"Value": 22.8,
"Unit": "C",
"UnitType": 17
},
"WetBulbTemperature": {
"Value": 15,
"Unit": "C",
"UnitType": 17
},
"DewPoint": {
"Value": 9.4,
"Unit": "C",
"UnitType": 17
},
"Wind": {
"Speed": {
"Value": 20.9,
"Unit": "km/h",
"UnitType": 7
},
"Direction": {
"Degrees": 260,
"Localized": "O",
"English": "W"
}
},
"WindGust": {
"Speed": {
"Value": 24.1,
"Unit": "km/h",
"UnitType": 7
},
"Direction": {
"Degrees": 260,
"Localized": "O",
"English": "W"
}
},
"RelativeHumidity": 43,
"IndoorRelativeHumidity": 43,
"Visibility": {
"Value": 16.1,
"Unit": "km",
"UnitType": 6
},
"Ceiling": {
"Value": 9754,
"Unit": "m",
"UnitType": 5
},
"UVIndex": 4,
"UVIndexText": "Modéré",
"PrecipitationProbability": 0,
"RainProbability": 0,
"SnowProbability": 0,
"IceProbability": 0,
"TotalLiquid": {
"Value": 0,
"Unit": "mm",
"UnitType": 3
},
"Rain": {
"Value": 0,
"Unit": "mm",
"UnitType": 3
},
"Snow": {
"Value": 0,
"Unit": "cm",
"UnitType": 4
},
"Ice": {
"Value": 0,
"Unit": "mm",
"UnitType": 3
},
"CloudCover": 64,
"MobileLink": "http://m.accuweather.com/fr/fr/boulogne-billancourt/133609/hourly-weather-forecast/133609?day=1&hbhhour=15&unit=c",
"Link": "http://www.accuweather.com/fr/fr/boulogne-billancourt/133609/hourly-weather-forecast/133609?day=1&hbhhour=15&unit=c"
},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{}

“Unnamed data” means data not identified by the attribute
In the above JSon, you may extract the DateTime with the query

  - platform: rest
    name: 'Accuweathercurrent'
    resource_template: "http://dataservice.accuweather.com/currentconditions/v1/xxxxx
      ?apikey={{states('input_text.accuweather_key')}}&language=fr-fr&details=true&metric=true"
    json_attributes_path: "$.[0].DateTime"
    value_template: '{{ value_json[0].DateTime }}' 
    scan_interval: 14400
    unit_of_measurement: °C
    headers:
      User-Agent: Home Assistant
      Content-Type: application/json``` 







In fact I was trying to issue the same request as the one I issue for the 5 days forecast
  • platform: rest
    name: ‘Accuweather’
    resource_template: “http://dataservice.accuweather.com/forecasts/v1/daily/5day/xxxxxx
    ?apikey={{states(‘input_text.accuweather_key’)}}&language=fr-fr&details=true&metric=true”
    json_attributes:
    - Headline
    - DailyForecasts
    value_template: ‘{{ value_json.headline}}’
    scan_interval: 14400
    headers:
    User-Agent: Home Assistant
    Content-Type: application/json
    • platform: template
      sensors:
      accuweather_resume:
      friendly_name: Résumé
      value_template: “{{ states.sensor.accuweather.attributes[‘Headline’].Text}}”
      accuweather_today_sunrise:
      friendly_name: Today Sunrise
      value_template: “{{ states.sensor.accuweather.attributes[‘DailyForecasts’][0].Sun.EpochRise | timestamp_custom(’%H:%M’, false)}}”

I issue one query to the accuweather site with the rest integration and then I use many sensors to read the data I need in the JSon received which is structured in a different way with blocks of data named, whereas in the hourly query the json start with [.
In the rest query I defined json_attributes = Headline and in the sensors I use the value_template {{ states.sensor.accuweather.attributes[‘Headline’].Text}}

I was wondering if its' possible to issue one query to get the hourly data (more than 255 characters) and then get the data I need for each hour with sensors reading the 'answer' to the rest query 

How to set the parameter of the rest query to be able to issue a sensor with "value_json[0].Rain.Value" to read the number of rain mm ?

I hope it's clearer.