How To - Telnet Interfaces (Devices)
The OpenRemote 2.0 controller has the option to control a variety of devices via the telnet protocol. This how-to will explain in detail how you can implement different actions like:
- Sending single commands
- Receiving and using status messages
- Extract status messages via Java regex (regular expressions)

This implementation is still in a development phase so the way different objects are handled can change in the course of time.
Different Types of Telnet Implementation
The telnet protocol can be implemented in a few different varieties. OpenRemote will support the CF and non-CF type connections. What this effectively means is that the telnet connection is able to directly send commands to the target with or without receiving a control prompt.
Example with CF (without control prompt):
Example without CF (with control prompt):
How do I know what kind of target I have?
Execute:
When you receive a message like the one below you have a target WITHOUT a control prompt.
Adding Telnet Commands in Designer and Adding a New Device
In the example shown a basic ON/OFF switch is created with a feedback sensor.
Logon to the Online Composer
1. Add a new Device
Add a new device by clicking the menu Devices --> New --> Device.
The "Vendor" and "Model" are dummy parameters and are only meant for administrative purposes.

2. Add an ON command
Now add 3 new commands by selecting the newly created device and click New --> New Command.
In this example an "on" command is sent to the target.
If your telnet target has a control prompt, the parameter below can be discarded.

The correct sequence should be: <null><pipe><command>
No spaces are allowed.
Click "Submit and Continue" to add a new command without loss of parameters.
3. Add an OFF command
Change only the "Name" and the "Command" itself

Click "Submit and Continue" to add a new command without loss of parameters.
4. Add a status feedback command (boolean of regular expression style)
For a switch sensor to work correctly a boolean "on" or "off" responds is required. The following 2 examples will show how these can be obtained in different ways.
4. 1. Add a status feedback command (boolean)
Sending the command:
To the target will respond in a boolean "on" or "off" which can be directly parsed.

4. 2. Add a status feedback command with regular expression (regex)
Not all devices have direct command which will show the status of the device. Handy enough we included a regular expression match to get the specific info needed. The chosen method is not the easiest, but it is the most flexible.

Parsing the command:
Will respond with the following output:
The part we need is the status "on" after the word "STATE". To parse "on" directly into the status variable a regular expression is needed which needs to be manually added to the controller.xml later on.
The regular expression needed to extract "on" from the total out put looks like:
Matching the expression to the output you have can be a bit taunting. As helpful as we are we supply you with a tool to get on your way.
Surf to Regular Expression Testing
- Enter the regular expression in the "Regular Expression" field
- Enter the (to be parsed) output in Testfield #1
- Ensure CANON_EQ and UNICODE_CASE are checked

Hit "Test" and the outcome will appear.
You will see that the box "group(1)" will contain the value "on". This is a correct boolean outcome.

Easy as that *kuch*
Sensors
Sensors in Openremote are used for relaying status data directly to the GUI frontend or for capturing different events. They rely per basis on a correct command which has been discusses in part 4.1.1
1. Add a switch sensor
Add a new switch sensor by selecting the "Device" -> New -> Sensor
Select the correct command for requesting the status and select "Switch" as the sensor type.

Switches
Switches in Openremote come only in a single type: ON/OFF
1. Adding a Switch
Add a new switch by selecting the "Device" -> New -> Switch
Select the correct switch sensor, on and off commands.

Final configuration
The content of your device should look like the model below now.


If you miss any components please go back and retrace your steps to see where you went wrong.
All the components should be there to display a correct function!
Comments (6)
Mar 11, 2011
philippe casteleyn says:
the spelling is : recEIving most easythe spelling is : recEIving
most easy
Sep 13, 2012
Juha Lindfors says:
Fixed (yes, ok it took quite some time :-D)Fixed (yes, ok it took quite some time :-D)
Mar 20, 2011
philippe casteleyn says:
follwing -> following Releases -> Releases. will included -> will inclu...follwing -> following
Releases -> Releases.
will included -> will include
telnet branch -> telnet branch.
do i know -> do I know (I am not sure any more)
i have -> I have
to the target -> to the target.
control prompt the parameter -> control prompt, the parameter
directly parsed -> directly parsed.
No spaces are allowed ->No spaces are allowed.
lick -> Click
receve -> receive
want wrong -> went wrong
I am not a Germanist. There might still be a style issue = the mixing of ?forms? of verbs
sending, receiving extract(ing)
adding, add
Sep 13, 2012
Juha Lindfors says:
Fixed. Thank you for proof-reading this page.Fixed. Thank you for proof-reading this page.
Sep 05, 2012
Art Balourdas says:
I spent several hours trying to get this to work finally realizing that there is...I spent several hours trying to get this to work finally realizing that there is not supposed to be a space between the null and the pipe and the command. null|command not null | command. The screen grabs above appear to have a space but apparently do not.
Dec 30
justme1968 says:
what device is this that allows telnet access to fs20 devices ?what device is this that allows telnet access to fs20 devices ?