Hello everyone.
I need your help to improve the accuweather integration.
I have two questions :
- 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 !!!
- 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 !