Skip to content

How to use OpenRemote with lagarto

dberenguer edited this page Aug 25, 2014 · 2 revisions

Introduction

OpenRemote is a powerful open source home automation software for iPhones, iPads and Android devices. OpenRemote's main strength is in our opinion the fact that anyone can create custom graphic layouts for their preferred mobile platforms and make them interoperate with a long list of home automation hardware. And all this for free, by simply using OpenRemote's online designer and uploading the generated files to a computer running OpenRemote Controller.

Before this release, panStamp was integrable with OpenRemote by means of the http engine included in lagarto-swap. An old tutorial explained this in fact. What makes the current release really interesting is that OpenRemote does not need polling values from lagarto anymore. New OpenRemote's protocol extension for lagarto is now able to receive events from lagarto without the need to be continuously querying our SWAP servers. Another advantage about the new extension is that users can create their custom GUI frontends faster from OpenRemote Designer.... but we will talk about this along the current tutorial.

Download and run OpenRemote

Firstly, you need to download OpenRemote Controller. Also download and install the latest version of lagarto as explained here. OpenRemote does not include the necessary binary ZeroMQ libraries (libzmq.so and libjzmq.so files on linux and some dll's on Windows). You have to locate these files on your computer and place them under OpenRemote/webapps/controller/WEB-INF/lib/native/.

Now it's time to run lagarto-max:

python lagarto-max.py

You can run OpenRemote after that:

Under Linux:

sh OpenRemote/bin/openremote.sh run

Under Windows:

OpenRemote\bin\openremote run

And finally run lagarto-swap:

python lagarto-swap.py

OpenRemote Designer

Now it's time co configure OpenRemote from the online Designer tool. Simply open the following URL from a web browser: http://composer.openremote.org/preview

and create the necessary commands, sensors and actuators. Let's start by creating a device called “Lagarto-SWAP” or whatever name you prefer. Once we have our device created we can then proceed with the creation of commands, sensors and actuators attached to our device.

Temperature sensor

Before creating a sensor object from OpenRemote Designer we need to define a command to link OpenRemote to the actual SWAP sensor. We can then create our sensor from Designer and attach it to the command previously defined.

1- Annotate the endpoint id appearing on the first column from lagarto-swap's Network page. This id uniquely represents each endpoint in lagarto-swap.

In the above example our Temperature0 endpoint has the id "10.12.0"

2- Create a new command from OpenRemote Designer and select “panStamp lagarto” from the protocol field.

  • Name : Enter your preferred name for the command
  • Protocol : Select "panStamp lagarto".
  • Server name : The name of the lagarto-swap server which our endpoint belongs to. This name can be found (and edited) in lagarto-swap's web GUI -> Preferences -> Lagarto Settings.
  • Endpoint ID : Endpoint ID taken from step 1.
  • New value : Leave it empty.

3- Create a sensor object from OpenRemote Designer's device manager

Enter a name for the sensor and attach it to the command defined in the precedent step. Set the "Type" field to "custom".

Binary actuator

1- Actuators, like sensors, need a command which will be used by OpenRemote to link to the real parameter in lagarto-swap. The only difference is that actuators need the "New value" field to be filled from the command window.

  • Name : Enter your preferred name for the command
  • Protocol : Select "panStamp lagarto".
  • Server name : The name of the lagarto-swap server
  • Endpoint ID : Endpoint ID
  • New value : "TOGGLE". This is the "trick" used to turn on and turn off binary loads using a single command from OpenRemote. Otherwise, you can create two different commands with "ON" and "OFF" values.

2- Create sensor object and attach it to the command defined in step 1. Set the type of sensor to "switch".

3- Create switch object. We have to attach the switch to the sensor defined in the precedent step and set both ON/OFF commands to our single binary command.

OpenRemote users will appreciate how a single command can be used to read and write endpoints with our protocol extension.

Level actuator

Level actuators, dimmers, DAC's (digital to analog converters) or PWM (pulse width modulation) outputs can be controlled using sliders from Openremote. The configuration procedure is similar to the binary input:

1- Create a new command for your output:

  • Name : Enter your preferred name for the command
  • Protocol : Select "panStamp lagarto".
  • Server name : The name of the lagarto-swap server
  • Endpoint ID : Endpoint ID.
  • New value : "${param}". This is OpenRemote's magic word to pass numeric values to the protocol handlers.

2- Create sensor object and attach it to the new command:

3- Create a new slider object and attach your new sensor and command to it:

Slider object

Like switches, sliders need to be attached to a sensor, responsible to read values from the real endpoint, and a "setValue" command which will be used to send new values to lagarto-swap. Again, a single command (cmd_Level0) is used to read and write values.

Design your GUI

Once arrived at this point you should see a list of objects similar to the following one:

Now you can design your custom GUI for your Android/iPhone device. Open the Panel view from Designer and create a new panel. We are omitting the cosmetic aspects in this tutorial.

  1. Create new screen.
  2. Place a grid and define its number or rows and columns
  3. Place a label for each analog input. In our example we should create the a label and attach it to the Temperature0 sensor.
  4. Place a switch for every binary actuator. In our example we should select Relay0 from the SwitchCommand selector.
  5. Place a slider for every level actuator, dimmer, ADC or PWM. We should then enter Level0 (Level0 slider object created from Designer's Device view) in the SliderCommand field for our current example.
  6. Save your work.

Upload design to OpenRemote Controller

Upload your Designer project to your OpenRemote controller by opening the following URL from a web browser: http://ip_addr_controller:8080/controller/. You will have to identify yourself and press the "Sync with Online Designer" button. Finally, open your graphic interface and select the OpenRemote Controller from the list.

Anti Swap

API for Anti Swap

Clone this wiki locally