Save this script as OpenWeatherMap.bat in your CumulusMX folder/directory:
Code: Select all
::
::Variables
::change here
set apikey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (your api key)
set station_id=xxxxxxxxxxxxxxxxxxxxxxxx (your station_id)
set curlpwd=C:\curl\bin (wherever curl is located)
::@echo off
setlocal
call :GetUnixTime UNIX_TIME
::echo %UNIX_TIME% seconds have elapsed since 1970-01-01 00:00:00
::
::use curl
::
%curlpwd%\curl.exe -g -X POST -H "Content-Type: application/json" --data "[{\"station_id\": \"%station_id%\",\"dt\": %UNIX_TIME%,\"temperature\": <#temp>,\"dewpoint\": <#dew>,\"wind_deg\": <#bearing>,\"wind_speed\": <#wspeed>,\"wind_gust\": <#wgust>,\"pressure\": <#press>,\"humidity\": <#hum>,\"rain_1h\": <#rhour>,\"rain_24h\": <#r24hour>}]" http://api.openweathermap.org/data/3.0/measurements?appid=%apikey%
goto :EOF
:GetUnixTime
setlocal enableextensions
for /f %%x in ('wmic path win32_utctime get /format:list ^| findstr "="') do (
set %%x)
set /a z=(14-100%Month%%%100)/12, y=10000%Year%%%10000-z
set /a ut=y*365+y/4-y/100+y/400+(153*(100%Month%%%100+12*z-3)+2)/5+Day-719469
set /a ut=ut*86400+100%Hour%%%100*3600+100%Minute%%%100*60+100%Second%%%100
endlocal & set "%1=%ut%" & goto :EOF
Then, using the CumulusMX console Settings tab, Internet Settings, ensure "Auto update" is enable in Web/FTP settings and set "Upload Interval" to 15 or higher.
Under "External Programs" add "C:\CumulusMx\openweather_processed.bat" in "Program"
Next, under "Settings", "Extra Web Files", add "C:\CumulusMX\OpenWeatherMap.bat" under "Local Filename" and "C:\CumulusMX\openweather_processed.bat" under "Remote Filename" (change locations to suit your individual installation). Ensure the tickbox under "Process" is ticked.
That's it. I tried using a simpler approach using "Custom HTTP" but OpenWeatherMap uses time in Linux Epoch format which isn't easily available in Windows. Thus the extra code in the script to derive it from Windows time.