Welcome to the Cumulus Support forum.

Latest Cumulus MX release v3.0.0 build 3050 - 1 May 2019.
Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014

See the Wiki for downloading either version.

OpenWeatherMap Script for CumulusMX in Windows 10

Discussion of version 3 of Cumulus, which runs on Windows, Linux, and OS X. All Cumulus MX queries in here, please.

Moderator: mcrossley

Post Reply
Posts: 7
Joined: Sat 24 May 2014 7:54 pm
Weather Station: Davis VP2
Operating System: Windows 7
Location: Calgary, Alberta, Canada

OpenWeatherMap Script for CumulusMX in Windows 10

Post by glarsen » Mon 16 Jul 2018 1:35 pm

Hi, I've created a script to send data from CumulusMX to OpenWeatherMap. It's based on the use of curl as suggested in a post elsewhere in this forum, but has been adapted to run on Windows 10. Since it uses curl, it should be easily adapted to run on other platforms as well.

Save this script as OpenWeatherMap.bat in your CumulusMX folder/directory:

Code: Select all

::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
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

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
You'll need to download and install curl for windows from "https://curl.haxx.se/download.html" as the version that comes with Windows 10 doesn't work properly. The downloaded version works more like that found in linux.

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.

Post Reply