Developing with RainMachine SDK

From RainMachine wiki page
Revision as of 00:40, 14 June 2016 by Admin (Talk | contribs)

Jump to: navigation, search

Developing with RainMachine SDK

RainMachine SDK allows developers to extend the functionality of RainMachine by creating custom pieces of code that will run directly on device itself along with the existing RainMachine software. While RainMachine API allows developer to control the device through a standard set of REST calls the SDK can be used to provide new functionality. At this moment the focus of the SDK is the creation of Weather Services (called parsers) but can be used for other functionality like automated restrictions, automatic program scheduling etc. The so called parsers, run periodically on device, and have access to the inner workings of RainMachine so their possibilities are endless.

Programming using the SDK is done in Python. The easiest way to use the SDK is by installing the PyCharm IDE.
This guide presents the steps for setting up the development environment in PyCharm.


Download the RainMachine SDK

Using git

git clone

Download a zip archive


Download and install Pycharm

PyCharm is a cross-platform Integrated Development Environment (IDE) used for programming in Python. It provides code analysis, a graphical debugger, an integrated unit tester, integration with version control systems. It works on Windows, Mac OS X and Linux. You can download the free community edition here:

Select project folder

Open PyCharm and select Open to choose the folder sdk-parser from where the rainmachine-developer-resources have been cloned/unpacked.


Edit Run configuration

To be able to run the project you must edit run configurations, go to "Run - Edit Configurations..." option, as shown below:


The parameters are separated by comma and have the following format: <RainMachine Name>,<TimeZone String>,<Latitude>,<Longitude>,<Elevation>.
Working directory must be set to the sdk-parser folder.


Edit or create parser

Parsers reside in RMParserFramework/parsers.
All *.py files in this folder will be automatically loaded when project is run.
Creating a new file following the How to_integrate RainMachine with different weather forecast services guide will automatically be loaded once the project is run.

Parsers Database

Parsers save their data on a sqlite database which is located in DB/<RainMachine Name> folder. This folder is automatically created at first run if doesn't exists. This data can be browsed with a sqlite browser: by viewing the parserData table. Parser-db-path.png

Run project


Press the Run button to execute the project. After initial setup all enabled parsers will be run every minute. This behavior can be changed by removing forceRunParser = True from the line 84. Removing this flag parsers will be executed by their parserInterval defined for each parser, which is how they are run on device.

Further reading

For more details about parser structure follow this document: How to integrate RainMachine with different weather forecast services