Difference between revisions of "Developing with RainMachine SDK"

From RainMachine wiki page
Jump to: navigation, search
(Run project)
m
Line 1: Line 1:
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
+
<span style="font-size: 188%;">Developing with RainMachine SDK</span><br>
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.
+
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.
 +
<br><br>
 +
Programming using the SDK is done in Python. The easiest way to use the SDK is by installing the PyCharm IDE.<br>
 +
This guide presents the steps for setting up the development environment in PyCharm.
  
 
= Download the RainMachine SDK =
 
= Download the RainMachine SDK =

Revision as of 00:26, 14 June 2016

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.

Contents

Download the RainMachine SDK

Using git

git clone https://github.com/sprinkler/rainmachine-developer-resources.git

Download a zip archive

wget https://github.com/sprinkler/rainmachine-developer-resources/archive/master.zip
unzip master.zip

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.

Pycharm-select-project.png

Edit Run configuration

To be able to run the project you must edit run configurations as shown below:

Pycharm-run-configuration.png

Pycharm-run-configuration-2.png

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. Pycharm-open-parser.png

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. Parser-db-path.png


Run project

Pycharm-run.png

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.

Further reading

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