OpenSprinkler Forums OpenSprinkler Unified Firmware Weather Adjustment using current temperature instead of average? Reply To: Weather Adjustment using current temperature instead of average?

#59568

Anonymous
Inactive

On another thread Ray suggested putting in a bug request, he doesn’t continuously watch the forum. I’m sure he is aware of the problem.
Of course OS is Open Source software and you’re encouraged to get your hands dirty, but I only know enough to be dangerous.

I had a play with the OpenWeatherMap API to see what is being returned, this is from Canberra Australia id=2172517
You need to register for an AppID code which I have replaced with #### here. The one baked into the OS I suspect is a paid one owned by Ray(?) which calls the 16 day forecast, you need a paid account to call that one, so the one below is the 5 day. Note it asks for imperial units.

http://api.openweathermap.org/data/2.5/forecast?id=2172517&APPID=####&units=imperial

Looking at the OpenSprinkler code on GitHub, I’m just assuming this is the right place to look.

https://github.com/OpenSprinkler/OpenSprinkler-Weather/blob/master/routes/weather.js

Line 46: is the API call to OW


forecastUrl = "http://api.openweathermap.org/data/2.5/forecast/daily?appid=" + OWM_API_KEY + "&units=imperial&lat=" + location[ 0 ] + "&lon=" + location[ 1 ];

My call above trying to emulate the GitHub code, calls Canberra, 5 days, imperial (I used the station ID as suggested by OW)

The call returns a heap of data in 3 hourly chunks over the next 5 days.

The next step is to see how all this feeds into Zimmerman. I suspect it stores all of the above data in a buffer to compute the Zimmerman parameters but I would have thought you’d ask for actual weather. In Canberra it only rains on you if you happen to be lucky enough to be under a passing cloud.

I wish I was retired so I had time to dive deeper into this.

[UPDATE] Found this: https://www.benlcollins.com/apps-script/beginner-apis/
[UPDATE} I just noticed on the web app, left hand side menu item > ‘System Diagnostics’ when clicked opens a dialog box which states the ‘Mean Temp 17.2C’ which is the current temperature at 9:27pm.
But the high temp today was 24.6C at 4:26pm and the minimum was 8C at 7:30am which makes it 16.3C ? Perhaps it’s reading the current temperature as the average?
[UPDATE] found this https://www.w3schools.com/js/js_json_parse.asp
I thought the Zimmerman function was applied to yesterday’s average temps not the average forecast?

[UPDATE 10 April] I’ve had a closer look and noticed a separate post about the API always returning mm not inches.
LINK

I had a play with the OWM API’s again specifically the code line 46 above, which I can’t test as it is a paid service.
It appears this is a forecast, and the max and min temps are fed into the Zimmerman calculation at line 130.
If there is no rain at the requested OWM site the json feed excludes a rain parameter and value, returning NaN (not a number), there is a test for this at line 73 which I haven’t been able to reproduce.

I found a few useful tools to look at this:
an online json viewer http://jsonviewer.stack.hu/
and the tryit javascript editor https://www.w3schools.com/js/tryit.asp?filename=tryjs_myfirst
You have to get your own APID as described above.

I couldn’t get line 73 weather.precip = data.list[ 0 ].rain ? parseFloat( data.list[ 0 ].rain || 0 ) : 0;
to work in tryit Editor, I’m still working on it.

Lets see what happens with the incorrect rain units…