Page 1 of 1

Openweathermap one-call-api [to replace darksy]

Posted: Monday 27 July 2020 12:39
by barts2108
Now that Darksky is going away, I noticed that openweathermaps has a newer API called one-call-api that contains a lot more information than the standard (free) api call.

Code: Select all

https://openweathermap.org/api/one-call-api
Is it possible to add a selection wich api you want to use for openweathermaps ? The normal "current weahter" (max 60 calls per minute) or the "one call api" (max 1000 calls per day). As far as I can see they are using the same free API key

Re: Openweathermap one-call-api [to replace darksy]

Posted: Monday 27 July 2020 13:40
by waaren
barts2108 wrote: Monday 27 July 2020 12:39 I noticed that openweathermaps has a newer API called one-call-api that contains a lot more information than the standard (free) api call.
The one-call-api has much more forecast information and do potentially require a lot more virtual sensors in domoticz. The current code for the openweathermaps hardware module would require significant work to be able to deal with both sets of data.

Maybe the dzVents script I created for this can be useful for you until someone wil find the time to work on this code ( I expect that it will then be in newly created module and that it will not happen in the near future because the domoticz volunteers with sufficient C++ skills are quite busy on other areas)

You will find the dzVents version here

Re: Openweathermap one-call-api [to replace darksy]

Posted: Monday 27 July 2020 19:13
by barts2108
Thanks, I will have a look at the script.

Reason I want to move is that DarkSky is fased out, and Buienradar is not reliable enough (Error: BuienRadar: Problem Connecting to Buienradar! (Check your Internet Connection!), or the infamous "thread seems to have ended unexpectedly" errors for Buienradar.

Recently received some BME280 board which I will build on ESP8266 boards, and extend my domoticz setup. Last few days made the original Frontpage.html working and did quite some cleanup and extension on that code (to my personal liking of course), some more steps to go in there and I will possible publish my code for the Frontpage as well.

Re: Openweathermap one-call-api [to replace darksy]

Posted: Monday 27 July 2020 19:38
by barts2108
I will also take a look at the OpenWeatherMap.cpp code to see if it is feasible to create somehting like a OpenWeatherMapOneCall.cpp

Re: Openweathermap one-call-api [to replace darksy]

Posted: Monday 27 July 2020 19:49
by Jan Jansen
That's very nice!

Thanks in advance

Re: Openweathermap one-call-api [to replace darksy]

Posted: Monday 27 July 2020 19:51
by waaren
barts2108 wrote: Monday 27 July 2020 19:38 I will also take a look at the OpenWeatherMap.cpp code to see if it is feasible to create somehting like a OpenWeatherMapOneCall.cpp
👍 That would be nice

Re: Openweathermap one-call-api [to replace darksy]

Posted: Wednesday 29 July 2020 15:05
by barts2108
On page https://www.domoticz.com/wiki/Developin ... rdware_tab

it says to do some work on the file www/app/HardwareController.js

I have a git clone on Ubuntu and one on Windows, but I cannot find that file. I is also not existing in the domoticz git. Propably here the file www/app/hardware/Hardware.js is meant. Is that correct ?

Re: Openweathermap one-call-api [to replace darksy]

Posted: Wednesday 29 July 2020 17:54
by waaren
barts2108 wrote: Wednesday 29 July 2020 15:05 On page https://www.domoticz.com/wiki/Developin ... rdware_tab

it says to do some work on the file www/app/HardwareController.js

I have a git clone on Ubuntu and one on Windows, but I cannot find that file. I is also not existing in the domoticz git. Propably here the file www/app/hardware/Hardware.js is meant. Is that correct ?
Yes. if you look in commit 56e8b6c8 with

Code: Select all

git show c56e8b6c8 | grep rename
you will find

Code: Select all

rename from www/app/HardwareController.js
rename to www/app/hardware/Hardware.js
I will update the wiki

Re: Openweathermap one-call-api [to replace darksy]

Posted: Wednesday 29 July 2020 21:20
by barts2108
Ok, meanwhile found how to make additional hardware plugin (struggling because I didn't see that the make builds the executable into the bin folder and I was executing from the dev-domoticz folder :roll:

Now exploring how I can make sure the fields are filled correctly because the One Call api requires lat=1.234&lon=5.432 in the url. I already see that the database does not support float type for hardware, so I probably have to do some checks on the string stored in the password field.

Re: Openweathermap one-call-api [to replace darksy]

Posted: Wednesday 29 July 2020 21:38
by waaren
barts2108 wrote: Wednesday 29 July 2020 21:20 Now exploring how I can make sure the fields are filled correctly because the One Call api requires lat=1.234&lon=5.432 in the url. I already see that the database does not support float type for hardware, so I probably have to do some checks on the string stored in the password field.
You could take the darkSky or Buienradar implementation as example. (they both store the lat / lon in the password field)

Re: Openweathermap one-call-api [to replace darksy]

Posted: Wednesday 29 July 2020 22:23
by barts2108
I have seen that. OneCall does only accept lat=1.234&lon=2.345 and in that format only. StationID or city name is not accepted in this api.

The response contains a lot of useful information (see samples below). I think current weather is free for 60 call's per minute. The hourly and daily info are free for max of 1000 calls per day ( say 1 call per 2 minutes ). A "minute forecast" may be (or may not yet be available) and it is possible to exclude either one or more of those sections.

Code: Select all

  "current": {
    "dt": 1596050589,
    "sunrise": 1595993828,
    "sunset": 1596052438,
    "temp": 14.68,
    "feels_like": 6.07,
    "pressure": 1014,
    "humidity": 75,
    "dew_point": 10.3,
    "uvi": 5.59,
    "clouds": 100,
    "visibility": 10000,
    "wind_speed": 12.48,
    "wind_deg": 286,
    "weather": [
      {
        "id": 500,
        "main": "Rain",
        "description": "light rain",
        "icon": "10d"
      }
    ],
    "rain": {
      "1h": 0.13
    }
  },
48 hours hourly forecast (showing 1 hour only)

Code: Select all

  "hourly": [
    {
      "dt": 1596049200,
      "temp": 14.68,
      "feels_like": 6.07,
      "pressure": 1014,
      "humidity": 75,
      "dew_point": 10.3,
      "clouds": 100,
      "visibility": 10000,
      "wind_speed": 12.48,
      "wind_deg": 286,
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10d"
        }
      ],
      "pop": 0.58,
      "rain": {
        "1h": 0.13
      }
    },
and 7 dayly forecast (showing 1 day only)

Code: Select all

  "daily": [
    {
      "dt": 1596020400,
      "sunrise": 1595993828,
      "sunset": 1596052438,
      "temp": {
        "day": 14.68,
        "min": 14.55,
        "max": 14.68,
        "night": 14.55,
        "eve": 14.68,
        "morn": 14.68
      },
      "feels_like": {
        "day": 5.96,
        "night": 7.4,
        "eve": 5.96,
        "morn": 5.96
      },
      "pressure": 1014,
      "humidity": 75,
      "dew_point": 10.3,
      "wind_speed": 12.63,
      "wind_deg": 283,
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10d"
        }
      ],
      "clouds": 100,
      "pop": 0.84,
      "rain": 0.81,
      "uvi": 5.59
    },

Re: Openweathermap one-call-api [to replace darksy]

Posted: Wednesday 29 July 2020 23:08
by barts2108
Devices are created... time to sleep. I guess testing, and then finding out how to do the pull request will be more time ;-)

Re: Openweathermap one-call-api [to replace darksy]

Posted: Sunday 02 August 2020 22:00
by kiddigital
I didn't see this thread earlier unfortunately so I wasn't aware that @barts2108 already started some work on the Open Weather Map module, but I created an update for this modules, see this Pull Request.

Not sure if it fills all the needs, but maybe it goes into the right direction and we can combine stuff and/or divide work?

Re: Openweathermap one-call-api [to replace darksy]

Posted: Thursday 13 August 2020 9:11
by Jan Jansen
kiddigital wrote: Sunday 02 August 2020 22:00 I didn't see this thread earlier unfortunately so I wasn't aware that @barts2108 already started some work on the Open Weather Map module, but I created an update for this modules, see this Pull Request.

Not sure if it fills all the needs, but maybe it goes into the right direction and we can combine stuff and/or divide work?
@ kiddidigital,

Thank you for your contribution to this major improvement. There is a lot to choose now. That in itself takes the necessary time for users :D .

best regards

(also thanks to others who contributed to this great improvement)