Sections

Developers

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 using the parserInterval specified on the source code (minimum 60 seconds), 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.

Using git

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: https://www.jetbrains.com/pycharm/download/

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 or create a new parser

Parsers reside in RMParserFramework/parsers. All *.py files in this folder will be automatically loaded when project is run.

For starting you can either edit existing example-parser.py or create a simple file named test-parser.py with the following content:

Edit Run configuration

If you want to test the automatic periodic execution you must edit run configurations, from "Run - Edit Configurations..." menu 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.

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: http://sqlitebrowser.org/ by viewing the parserData table.

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 rmParserManager.py line 84.Removing this flag parsers will be executed by their parserInterval defined for each parser, which is how they are run on device.