dimfalk / netatmo.weather

R wrapper for Netatmo Weather API
GNU General Public License v3.0
3 stars 0 forks source link

`get_measure()`: allow queries of `date_min/max_*` #33

Closed dimfalk closed 2 years ago

dimfalk commented 2 years ago
"date_min_pressure" 
"date_max_pressure"

"date_min_temp"
"date_max_temp"

"date_min_hum"
"date_max_hum"

"date_min_gust"
"date_max_gust"
dimfalk commented 2 years ago

Date data are only available for scales from 1 day to 1 month and unit is Local Unix Time in seconds.

https://dev.netatmo.com/apidocumentation/weather

dimfalk commented 2 years ago

Example:

https://api.netatmo.com/api/getmeasure?device_id=70%3Aee%3A50%3A6b%3A34%3A74&module_id=02%3A00%3A00%3A6b%3A42%3Aa6&type=date_max_hum&optimize=false&real_time=false&scale=1day&access_token=xxx

jsonlite::read_json("foo.json") |> unlist() |> as.numeric() |> as.POSIXct(origin = "1970-01-01") |> tail(10)

#> [1] "2022-10-19 09:55:55 CEST" "2022-10-20 04:13:57 CEST" "2022-10-21 03:10:32 CEST" "2022-10-22 06:25:11 CEST" "2022-10-23 04:45:01 CEST"  
#> [6] "2022-10-24 20:59:49 CEST" "2022-10-25 01:27:18 CEST" "2022-10-26 00:31:34 CEST" "2022-10-27 05:06:32 CEST" "2022-10-28 00:03:53 CEST"

Basically, you get what you ask for. If you really wanted to know the timestamps of the daily minimum/maximum pressure/temperature/humidity recorded (without knowing the observed value per se), you're good to go.

On the other hand, it's hard to believe timestamps are recorded at 1 second resolution, e.g. daily maximum relhum at "2022-10-26 00:31:34 CEST". And even if Netatmo did, who needs this kind of precision?

dimfalk commented 2 years ago

Coming from original timeseries acquired, the unique selling point of these parameters is not clear yet. All information necessary is availabe, e.g. daily max. relhum timestamps can be derived easily from the xts objects created.

library(netatmo.weather)
fetch_token()
stations <- get_publicdata(ext = get_extent(x = c(6.89, 51.34, 7.13, 51.53)))
xts <- get_measure(stations[1,], period = get_period(), par = "humidity")[[1]]
plot(xts, col = "blue", main = "relative humidity, 5-minutely")

Rplot

dimfalk commented 2 years ago

Idea to be dismissed for now. May be reopened at a later stage when needed.