Openweathermap one-call-api [to replace darksy]

Moderator: leecollings

Post Reply
User avatar
barts2108
Posts: 25
Joined: Wednesday 17 June 2020 18:31
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Arnhem
Contact:

Openweathermap one-call-api [to replace darksy]

Post 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
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
barts2108
Posts: 25
Joined: Wednesday 17 June 2020 18:31
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Arnhem
Contact:

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

Post 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.
User avatar
barts2108
Posts: 25
Joined: Wednesday 17 June 2020 18:31
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Arnhem
Contact:

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

Post 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
Jan Jansen
Posts: 229
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

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

Post by Jan Jansen »

That's very nice!

Thanks in advance
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
barts2108
Posts: 25
Joined: Wednesday 17 June 2020 18:31
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Arnhem
Contact:

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

Post 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 ?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
barts2108
Posts: 25
Joined: Wednesday 17 June 2020 18:31
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Arnhem
Contact:

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

Post 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.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
barts2108
Posts: 25
Joined: Wednesday 17 June 2020 18:31
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Arnhem
Contact:

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

Post 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
    },
User avatar
barts2108
Posts: 25
Joined: Wednesday 17 June 2020 18:31
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Arnhem
Contact:

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

Post 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 ;-)
User avatar
kiddigital
Posts: 435
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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?
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
Jan Jansen
Posts: 229
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

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

Post 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)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests