This page last changed on Feb 02, 2011 by kurrazyman.

Anyone interested in the Telnet command may have realised that in the current release the read method has not been implemented, and so you cannot use telnet commands to get the status of sensors. I have created a branch with an implementation of the status read method.

http://openremote.svn.sourceforge.net/svnroot/openremote/branches/feature/Controller_2_0_0_Alpha11_telnet/

Modified Files

The only files that have been altered in this branch are the TelnetCommand.java and TelnetCommandBuilder.java (in the protocol folder)

How it works

The idea is similar to the send method, so the first part of the command (before the '|') is the string to wait for before sending the next part of the command, multiple commands (e.g. OK|command1|YES|command2 ) can be used and each time the response back is added to a buffer and processed at the end. The statusFilter regex is then applied to the response text and the statusFilterGroup number is used to determine which group number contains the result in the regex match (need to be familiar with regex). The statusDefault is the response returned if the filter cannot be applied or no result is returned.

Usage

You'll need to add some attributes to your telnet command in the controller.xml after you have imported your controller.xml from the designer (have a look at TelnetCommandBuilder you can see the properties it's looking for), below is an example telnet command with these new properties set: -

    <command id="340" protocol="telnet">
      <property name="port" value="6601" />
      <property name="command" value="OK|currentsong" />
      <property name="ipAddress" value="192.168.1.74" />
      <property name="statusFilter" value="^(?i)(?s)(?m).*artist.\s(.+).title.*$" />
      <property name="statusFilterGroup" value="1" />
      <property name="statusDefault" value="None" />      
    </command>

Richard,

Thank you very much for taking the lead on this. I plan on rolling this into the release branches as soon as I can (still traveling this week). I know several people are waiting for it.

And also congratulations on making a contribution to OpenRemote. You're one of the few and we deeply appreciate it.

– Juha

Posted by juha at Feb 03, 2011 12:26

I hope I can play a bigger role in the development of this great project (albeit on a slightly selfish level as I have a new house build underway at the moment and I need a Home Automation Control System that can integrate the various automation/AV elements together and I think OpenRemote is a good base to work from).

I've been using my newly implemented Telnet read status and I've come to a stumbling block that I know has been discussed (notably for KNX); if I have multiple sensors that need to get their status from the same telnet server only one connection can be made at any one time but with the current Openremote configuration it seems that multiple connections are being attempted at the same time.

There's some notes in the KNXConnnectionBuilder.java file discussing this sort of issue and I'm looking to implement a connection manager for the telnet protocol also, can't help thinking that a generic solution would be best here for all current and future protocols; what are your thoughts/plans on this?

Rich

Posted by kurrazyman at Feb 03, 2011 12:43

If anyone is interested there's a great online regex tool which I use for prooving out my regex to statusFilter property, you can paste in multiple lines of text (your telnet response text) and also see the matching group numbers and content:

http://www.fileformat.info/tool/regex.htm

You need to set the CANON_EQ and UNICODE_CASE options as these have been hardcoded into the Regex Pattern (they can't be set in the expression). Another pointer, the DOTALL (?s) and MULTILINE (?m) options are your friends when working with blocks of text which includes Carriage Returns and/or Line Feeds.

Posted by kurrazyman at Feb 03, 2011 12:52

Although ive only been testing so far ive run into similair issues. The plugin I use for Homeseer can also only accept 1 connection from each source IP at any one time. With only a couple of sensors I can run into conflicts.

For me the solution would be to abstract some of the protocol information to a per-device setup rather than per-command. So i can configure port + destination IP just once per device and have a single IP session for all commands/sensors to any given device. All commands for that device would inherit those settings.

I wish I knew enough JAVA to contribute directly......but its going to take me a while.

Posted by deanox at Feb 03, 2011 17:25

Hi Richard,

At 1st thanks for the effort so far and as requested here is my first test report.

In the designer i added a standard switch with NO sensor and only a on/of command set. So very basic

The error i get is the same as before when i did not modify the TelnetCommand.java

 [Controller]2011-02-04 12:20:09,450 INFO [HTTP-Thread-3] org.openremote.controller.protocol.telnet.TelnetCommand.waitForString(245) | Read before running into timeout:
[Controller]2011-02-04 12:20:09,452 ERROR [HTTP-Thread-3] org.openremote.controller.protocol.telnet.TelnetCommand.send(216) | could not perform telnetEvent
java.lang.Exception: Response timed-out waiting for "set Stalamp_KL on"
	at org.openremote.controller.protocol.telnet.TelnetCommand.waitForString(TelnetCommand.java:246)
	at org.openremote.controller.protocol.telnet.TelnetCommand.send(TelnetCommand.java:205)
	at org.openremote.controller.protocol.telnet.TelnetCommand.send(TelnetCommand.java:188)
	at org.openremote.controller.service.impl.ControlCommandServiceImpl.trigger(ControlCommandServiceImpl.java:56)
	at org.openremote.controller.rest.ControlCommandRESTServlet.doPost(ControlCommandRESTServlet.java:85)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.openremote.controller.rest.support.json.JSONCallbackFilter.doFilter(JSONCallbackFilter.java:65)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:354)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)

I took a look at the controller.xml but i could find anything strange. What could be the error in this?

Posted by kide at Feb 04, 2011 11:26

Hi Ernst,

Looking at the error there I would say the problem is with your Telnet command itself; it looks like you haven't specified a 'waitForString' that the telnet command expects to get sent from the Telnet server before it initiates the actual command you want to send it (this is to make sure the telnet session is established and ready for input). If you don't know what this waitForString value should be simply manually create a telnet session to the server you are trying to connect to (telnet command in dos and linux e.g. telnet x.x.x.x 1234 where x.x.x.x is the IP address and 1234 is the port number) once connected the server should give some sort of prompt and you need to set this prompt string as your waitForString.

As an example if I connect to pulseaudio via telnet it responds with '>>>' and I can then enter my command 'setvol 0' for example. So in Openremote my telnet command would be:

>>>|setvol 0

If you get the send command working then that's a good start.

When using a telnet command as a slider set command to get the current value of the slider you need to use the ${param} string, so in my example above with the setvol command my telnet command string would become:

>>>|setvol ${param}

Good Luck

Rich

Posted by kurrazyman at Feb 04, 2011 11:45

I know what you mean but my Telnet reciever is in no such need of doing this.

If i telnet to my device "telnet <ip> <port>"  i can directly send a "set Stalamp_KL on" without getting a decent prompt 1st.

I tried it with hitting <enter> and i get a prompt like " fhem>"  where i can type commando's but i dont need to...

Would it be able to send a <enter> before executing the command?

Could you look at this link were we've discussed and (partially) fixed it telnet

Its a work around but more people seem to have problenms with it.

Posted by kide at Feb 04, 2011 11:58

I modified the TelnetCommand.java so it doesnt wait and switching on works ok. The command is sent and picked up.

However when the controller starts i see the following comming up.

[Controller]2011-02-04 13:25:03,363 INFO [Thread-7] org.openremote.controller.net.RoundRobinTCPServer.run(48) | TCP Server : started successfully for receiving groupmember urls...
[Controller]2011-02-04 13:25:03,363 INFO [Thread-7] org.openremote.controller.net.RoundRobinTCPServer.run(49) | TCP Server : Waiting for groupmember response...
[Controller]2011-02-04 13:25:03,593 INFO [Thread-8] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(263) | send: { $value{Stalamp_KL} }
[Controller]2011-02-04 13:25:03,594 INFO [Thread-8] org.openremote.controller.protocol.telnet.TelnetCommand.readString(282) | received:
[Controller]2011-02-04 13:25:05,198 INFO [Timer-0] org.quartz.utils.UpdateChecker.doCheck(86) | New update(s) found: 1.8.4 [http://www.terracotta.org/kit/reflector?kitID=default&pageID=QuartzChangeLog]

The sensor command is sent but nothing is recorded as a respons. If i trace the tcpstream i see the command and also its respons being: on

Posted by kide at Feb 04, 2011 12:31

Hi Ernst,

Rather than modifying the TelnetCommand.java file you could have tried using an empty string for the WaitForString i.e. ' |commandhere' haven't got the source code in front of me but this should work.

With regards to not getting a response the command is it your intention to send the string '{ $value{Stalamp_KL} }' or is there some variable substitution needed?

Posted by kurrazyman at Feb 04, 2011 14:07

Hi Richard,

I Tried your sugestion with the modified command " |commandhere" but the same problem occurs. It just times out. Or i'm doing something totally wrong here 

my controller.xml:

   ^M
    "529" protocol="telnet">^M
      "port" value="7072" />^M
      "command" value=" |set Stalamp_KL on" />^M
      "ipAddress" value="192.168.10.110" />^M
    ^M
    "530" protocol="telnet">^M
      "port" value="7072" />^M
      "command" value=" |set Stalamp_KL off" />^M
      "ipAddress" value="192.168.10.110" />^M
    ^M
  ^M
  ^M

And my controller.log

 [Controller]2011-02-04 18:13:16,586 ERROR [HTTP-Thread-2] org.openremote.controller.protocol.telnet.TelnetCommand.send(216) | could not perform telnetEvent
java.lang.Exception: Response timed-out waiting for " "
	at org.openremote.controller.protocol.telnet.TelnetCommand.waitForString(TelnetCommand.java:246)
	at org.openremote.controller.protocol.telnet.TelnetCommand.send(TelnetCommand.java:205)
	at org.openremote.controller.protocol.telnet.TelnetCommand.send(TelnetCommand.java:188)
	at org.openremote.controller.service.impl.ControlCommandServiceImpl.trigger(ControlCommandServiceImpl.java:56)
	at org.openremote.controller.rest.ControlCommandRESTServlet.doPost(ControlCommandRESTServlet.java:85)

To comment on my send string. The string 

{ $value{Stalamp_KL}}

  needs to be executed exactly like this on the telnet prompt. Dont ask my why but this is how FHEM require it to get the status of a switch. it will return "on" "off" or "dimxx%"

I Also passed the "respond prompt" issue back in the usergroup and i'm awaiting responds.

Posted by kide at Feb 04, 2011 17:24

ok this is a bit embarising but after a long "tug of war" within the FHEM usergroup i can to the conclusion that FHEM is not supporting a telnet library but a normal TCP/IP socket library.

They use telnet just as a tool and they not support telnet as a protocol in complete. Not that its working now but that is something else i've got to figure out.

Posted by kide at Feb 05, 2011 17:05

Hi Ernst,

Well at least you figured something out!

Looking at the controller.xml that you posted yesterday if you are trying to use the read method that I've implemented in my telnet branch then you need to manually specify the extra properties in the controller.xml as well (as per my initial post above).

I don't think the read method has been implemented in the the TCP/IP protocol yet either.

Even though your telnet server for FHEM isn't supported if it exists and you can successfully send commands to it and they are actioned then it should be usable with Openremote. I am just making a change to my branch so that you can specify a null waitForString value so the command would become 'null|commandhere'.

Posted by kurrazyman at Feb 05, 2011 17:15

Ok great i'll be waiting for the mod in your branch. But lets be carefull that you dont make modifications to get something to work that doesnt support the protocol in complete. I mean its great to get it working but maybe we are introducing overhead that normally wouldnt be nessecary.

I checked the status change for TCP/IP sockets and it seems NOT implemented as far as i can relate from the logfiles. My java is no where near good to actually check it in he code.Could you?

My controller.log tells me this:

 [Controller]2011-02-05 19:18:38,297 INFO [HTTP-Thread-6] org.openremote.controller.rest.RoundRobinRESTServlet.doPost(63) | Start RoundRobin group member REST service. at 2011-02-05 19:18:38
[Controller]2011-02-05 19:18:38,316 INFO [Thread-12] org.openremote.controller.net.RoundRobinUDPServer$UDPServerDealThread.run(132) | UDP Server : Received the controller multicast request from the same group floor20
[Controller]2011-02-05 19:18:38,317 INFO [Thread-7] org.openremote.controller.net.RoundRobinTCPServer.run(53) | TCP Server : a new groupmember socket established...
[Controller]2011-02-05 19:18:38,320 INFO [Thread-13] org.openremote.controller.net.RoundRobinTCPServer$AppendGroupMemberThread.run(80) | TCP Server deal thread : Ready for receiving groupmember url ...
[Controller]2011-02-05 19:18:38,321 INFO [Thread-13] org.openremote.controller.net.RoundRobinTCPServer$AppendGroupMemberThread.run(84) | TCP Server deal thread : received a groupmember url : http://192.168.10.108:8080/controller
[Controller]2011-02-05 19:18:38,694 INFO [HTTP-Thread-8] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(77) | Started polling at 2011-02-05 19:18:38
[Controller]2011-02-05 19:18:38,696 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(74) | Querying changed state from ChangedStatus table...
[Controller]2011-02-05 19:18:38,697 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(89) | Found: [device => 030070774321090, sensorIDs => 531] in ChangedStatus table.
[Controller]2011-02-05 19:18:38,698 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(107) | DEVICEID:030070774321090	sensorID:[531]statusChangedSensorID:[]Waiting...
[Controller]2011-02-05 19:18:38,817 INFO [HTTP-Thread-6] org.openremote.controller.rest.RoundRobinRESTServlet.doPost(86) | Finished RoundRobin group member REST service.  at 2011-02-05 19:18:38
[Controller]2011-02-05 19:19:28,699 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(103) | Had timeout for waiting status change.
[Controller]2011-02-05 19:19:28,701 INFO [HTTP-Thread-8] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(116) | Finished polling at 2011-02-05 19:19:28
[Controller]2011-02-05 19:19:28,721 INFO [HTTP-Thread-8] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(77) | Started polling at 2011-02-05 19:19:28
[Controller]2011-02-05 19:19:28,723 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(74) | Querying changed state from ChangedStatus table...
[Controller]2011-02-05 19:19:28,724 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(89) | Found: [device => 030070774321090, sensorIDs => 531] in ChangedStatus table.
[Controller]2011-02-05 19:19:28,724 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(107) | DEVICEID:030070774321090	sensorID:[531]statusChangedSensorID:[]Waiting...
[Controller]2011-02-05 19:20:18,725 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(103) | Had timeout for waiting status change.
[Controller]2011-02-05 19:20:18,727 INFO [HTTP-Thread-8] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(116) | Finished polling at 2011-02-05 19:20:18
[Controller]2011-02-05 19:20:18,749 INFO [HTTP-Thread-8] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(77) | Started polling at 2011-02-05 19:20:18
[Controller]2011-02-05 19:20:18,750 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(74) | Querying changed state from ChangedStatus table...
[Controller]2011-02-05 19:20:18,751 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(89) | Found: [device => 030070774321090, sensorIDs => 531] in ChangedStatus table.
[Controller]2011-02-05 19:20:18,752 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(107) | DEVICEID:030070774321090	sensorID:[531]statusChangedSensorID:[]Waiting...
[Controller]2011-02-05 19:21:08,753 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(103) | Had timeout for waiting status change.
[Controller]2011-02-05 19:21:08,755 INFO [HTTP-Thread-8] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(116) | Finished polling at 2011-02-05 19:21:08
[Controller]2011-02-05 19:21:08,777 INFO [HTTP-Thread-8] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(77) | Started polling at 2011-02-05 19:21:08
[Controller]2011-02-05 19:21:08,778 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(74) | Querying changed state from ChangedStatus table...
[Controller]2011-02-05 19:21:08,779 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(89) | Found: [device => 030070774321090, sensorIDs => 531] in ChangedStatus table.
[Controller]2011-02-05 19:21:08,780 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(107) | DEVICEID:030070774321090	sensorID:[531]statusChangedSensorID:[]Waiting...
[Controller]2011-02-05 19:21:58,781 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(103) | Had timeout for waiting status change.
[Controller]2011-02-05 19:21:58,782 INFO [HTTP-Thread-8] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(116) | Finished polling at 2011-02-05 19:21:58
[Controller]2011-02-05 19:21:58,805 INFO [HTTP-Thread-8] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(77) | Started polling at 2011-02-05 19:21:58
[Controller]2011-02-05 19:21:58,807 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(74) | Querying changed state from ChangedStatus table...
[Controller]2011-02-05 19:21:58,808 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(89) | Found: [device => 030070774321090, sensorIDs => 531] in ChangedStatus table.
[Controller]2011-02-05 19:21:58,809 INFO [HTTP-Thread-8] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(107) | DEVICEID:030070774321090	sensorID:[531]statusChangedSensorID:[]Waiting...

I checked the target host and no packets are comming in on the desired port so i support your oppinion that status checking for TCP sockets is not implemented. But this will come in a later part/separate topic.

Please page me when your branch is syned and i'll test it with your mod.

To be clear on the content of the controller.xml. If i'm correct it should contain something like:

     <command id="340" protocol="telnet">
      <property name="port" value="7072" />
      <property name="command" value="null|{ $value{Stalamp_KL}}" />
      <property name="ipAddress" value="192.168.10.110" />
      <property name="statusDefault" value="None" />
    </command>

And i can leave the filter out?

      <property name="statusFilter" value="^(?i)(?s)(?m).*artist.\s(.+).title.*$" />
      <property name="statusFilterGroup" value="1" />

right?

Posted by kide at Feb 05, 2011 18:35

I haven't checked the TCP protocol source code but Juha told me the other day that the read status methods needed implementing for the HTTP and TCP/IP protocols.

Back onto the Telnet command, no you can't leave out the statusFilter or statusFilterGroup properties. I understand that you want to return the entire response so what you need for these properties is:

<property name="statusFilter" value="^(?i)(?s)(?m)(.*)$" />
<property name="statusFilterGroup" value="1" />

Rich

Posted by kurrazyman at Feb 05, 2011 18:44

Yes, i would like to read the complete return since its "on" or "off" if its regarding a status for a switch.

If you could explain me how the "Statusfilter" and the "StatusfilterGroup" work i could filter it much more easily from another command and i can included it in the "Telnet Howto" i'm creating.

You can contact me at ernst[dot]cozijnsen[at]gmail[dot]com

Posted by kide at Feb 05, 2011 19:12

I am going to modify the read method so it works without the statusFilter and statusFilterGroup properties for cases like yours; once this is committed to subversion I will let you know.

To explain the statusFilter:

The read method stores the response returned from the telnet command, the statusFilter regular expression is then applied to the entire response. An understanding of regular expressions is needed but basically when a match is found then a match group is created (like a string array) where index 0 contains the entire matched string and all other indices are dependent on whether or not groups are used in the regular expression (groups are created by enclosing part of the expression in brackets). If a requested group doesn't exist then null is returned. A practical example explains things better I think:

I want to create a slider to get/set the current volume of an MPD server via telnet, there is a telnet command for MPD to set the volume called 'setvol int' but there isn't a command to just get the volume instead there is a 'status' command that returns lots of info, a typical response for this command would be:

OK MPD 0.15.0
status
volume: 65
repeat: 0
random: 0
single: 0
consume: 0
playlist: 18
playlistlength: 14
xfade: 0
state: play
song: 0
songid: 1
time: 15:262
bitrate: 160
audio: 44100:24:2
nextsong: 1
nextsongid: 2
OK

I only want the number after the volume line so I need to filter the response, the statusFilter regex to do this is:

^(?i)(?s).*volume.\s(.\d+).*$

You'll notice the brackets around the '.\d+', this tells the regex engine to store that part of the matched response in statusFilterGroup 1 (group 0 always contains the entire match).

So my Slider would have two telnet commands associated with it, the first to set the volume the second to get the volume:

    <command id="" protocol="telnet">
      <property name="port" value="6602" />
      <property name="command" value="OK|setvol ${param}" />
      <property name="ipAddress" value="192.168.1.74" />
    </command>
    <command id="" protocol="telnet">
      <property name="port" value="6601" />
      <property name="command" value="OK|status" />
      <property name="ipAddress" value="192.168.1.74" />
      <property name="statusFilter" value="^(?i)(?s).*volume.\s(.\d+).*$" />
      <property name="statusFilterGroup" value="1" />
      <property name="statusDefault" value="0" />      
    </command>

I am also adding an optional timeOut property because at the moment it is hardcoded to 1 Second, example to change the telnet command time out to 2 seconds:

<property name="timeOut" value="2" /> 

It would be great if you can put all this into a TELNET HOW TO GUIDE, highlighting the required properties and the optional ones.

Rich

Posted by kurrazyman at Feb 05, 2011 19:50

I've now updated the branch with the following changes:

Added: Ability for null waitForString value so command would become 'null|commandhere' for telnet servers with no prompt or to keep reading back until timeout expires

Added: timeOut property support to override default 1 second time out

Updated: Read method now works without statusFilter and statusFilterGroup properties (entire response is returned to the sensor)

Posted by kurrazyman at Feb 05, 2011 23:52

the "null|<commandhere>" works splendid  now. I can send a command which executes (and works)

Only my regular expression knowledge is (very) limited as i just experienced

If we want this to be more accessible then we need to include some very good examples that explain the basics because without it 9 out of 10 people will stop using because its simply to difficult and not accessible.

Not everybody is a ACE programmer.

I'm trying to select the "on" after "STATE" in the following output:

    BTN        03
   DEF        2611 03
   IODev      CUNO1
   NAME       Stalamp_KL
   NR         22
   STATE      on
   TYPE       FS20
   XMIT       2611
   Code:
     1          2611 03
   Readings:
     2011-02-06 13:14:34   state           on
Attributes:
   loglevel   5
   model      fs20di
   room       Huiskamer

I poked around in eclipse to give me a hand with the expressions but my knowledge ends with using "sed" and "awk"

I'll try to find a matching case but a hint would be nice. Maybe it would be a good thing to have a kind of test script which helpes with the expressions and testing it.

Posted by kide at Feb 06, 2011 13:19

Hi Ernst,

Glad things are working for you now, I've done some testing my end and everything should behave.

Yes I agree that the documentation and examples is the key; unfortunately I had to resort to using the regex filter method as it is extremely powerful and should be able to get out any string from a stream of text but the learning curve is a little
steep. The link I put earlier in this thread is what I use for prooving/testing my regex (I'm definitely not an expert but getting to grips with it slowly - it's like learning another language)

http://www.fileformat.info/tool/regex.htm

Looking at your case above:

1) Go to the regex tester at fileformat.info
2) Paste your response text into the Test String #1 field
3) Click the CANON\_EQ and UNICODE\_CASE checkboxes
4) Begin developing your regex
5) To get you on your way, for what you want you need to use the following regex:

^(?i)(?m).*state\s+(\w+).*$

6) Click the Test button and you'll see the matches and their group number

Rich
Rich

Posted by kurrazyman at Feb 06, 2011 15:04

Hi Rich,

Thanks for the hint but ehh..... if i fill in the required parameters and hit "Test" i get a result which says: "Matches NO" & "groupCount 1"

If my assumption is is right the total outcome would be that the value "on" should be saved in the 1st group right?

I did a test with your expression and i got the following:

 [Controller]2011-02-06 16:41:22,233 INFO [Thread-8] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(327) | send: list Stalamp_KL
[Controller]2011-02-06 16:41:23,251 INFO [Thread-8] org.openremote.controller.protocol.telnet.TelnetCommand.readString(349) | received: Internals:
   BTN        03
   DEF        2611 03
   IODev      CUNO1
   NAME       Stalamp_KL
   NR         22
   STATE      on
   TYPE       FS20
   XMIT       2611
   Code:
     1          2611 03
   Readings:
     2011-02-06 13:14:34   state           on
Attributes:
   loglevel   5
   model      fs20di
   room       Huiskamer


[Controller]2011-02-06 16:41:23,252 INFO [Thread-8] org.openremote.controller.protocol.telnet.TelnetCommand.read(372) | Telnet Read Status: No Match using Regex: '^(?i)(?m).*state\s+(\w+).*$' on response from command 'null|list Stalamp_KL'

One big hocuspocus for me

Posted by kide at Feb 06, 2011 15:37

Sorry Ernst,

Try

^(?i)(?s)(?m).*state\s+(\w+).*$
Posted by kurrazyman at Feb 06, 2011 15:48

Ok that seemed to work (i have to figure out why... but that will come)

The next issue is what i see in the controller.log

 [Controller]2011-02-06 16:56:16,813 INFO [Thread-8] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(327) | send: list Stalamp_KL
[Controller]2011-02-06 16:56:17,817 INFO [Thread-8] org.openremote.controller.protocol.telnet.TelnetCommand.readString(349) | received: Internals:
   BTN        03
   DEF        2611 03
   IODev      CUNO1
   NAME       Stalamp_KL
   NR         22
   STATE      on
   TYPE       FS20
   XMIT       2611
   Code:
     1          2611 03
   Readings:
     2011-02-06 16:56:03   state           on
Attributes:
   loglevel   5
   model      fs20di
   room       Huiskamer


It look all nice but the status of the button is not updated and when i push my switch it sends the command:

 [Controller]2011-02-06 16:56:01,400 INFO [HTTP-Thread-4] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(327) | send: set Stalamp_KL on

Also after this the status of the button doesnt change to "on".

Is it normal that the status request keeps polling almost every second?

sadsa

Posted by kide at Feb 06, 2011 16:00

I'm pretty sure now then that your sensor will be getting an 'on' or 'off' string back from the telnet command read method.

I haven't done much testing with switches but I know labels work fine so if you can add a label to your panel and tie it to a custom sensor (leave the state map empty) if you then turn your lights on/off with another button (assuming you can successfully send on/off commands) then you should see the label text change to show the current state of the light.

Unfortunately all sensors poll their server every 1 second (apart from maybe KNX because some extra work has been done for that protocol) which is bad news especially when you have lots of sensors all connecting to the same server.

I am just about to start looking into a better approach for this so watch out for another branch!

Rich

Posted by kurrazyman at Feb 06, 2011 16:11

I tested it with a label as you said but even if i start with the "state on"  its not reflected back in the button on the label.

When i reload the UI panel from the controller i see the following in the controller.log

 [Controller]2011-02-06 17:31:02,219 INFO [Thread-8] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(327) | send: list Stalamp_KL
[Controller]2011-02-06 17:31:02,407 INFO [HTTP-Thread-7] org.openremote.controller.rest.RoundRobinRESTServlet.doPost(65) | Start RoundRobin group member REST service. at 2011-02-06 17:31:02
[Controller]2011-02-06 17:31:02,427 INFO [Thread-169] org.openremote.controller.net.RoundRobinUDPServer$UDPServerDealThread.run(132) | UDP Server : Received the controller multicast request from the same group floor20
[Controller]2011-02-06 17:31:02,428 INFO [Thread-7] org.openremote.controller.net.RoundRobinTCPServer.run(53) | TCP Server : a new groupmember socket established...
[Controller]2011-02-06 17:31:02,428 INFO [Thread-170] org.openremote.controller.net.RoundRobinTCPServer$AppendGroupMemberThread.run(80) | TCP Server deal thread : Ready for receiving groupmember url ...
[Controller]2011-02-06 17:31:02,429 INFO [Thread-170] org.openremote.controller.net.RoundRobinTCPServer$AppendGroupMemberThread.run(84) | TCP Server deal thread : received a groupmember url : http://192.168.10.108:8080/controller
[Controller]2011-02-06 17:31:02,797 INFO [HTTP-Thread-10] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(79) | Started polling at 2011-02-06 17:31:02
[Controller]2011-02-06 17:31:02,798 INFO [HTTP-Thread-10] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(74) | Querying changed state from ChangedStatus table...
[Controller]2011-02-06 17:31:02,799 INFO [HTTP-Thread-10] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(89) | Found: [device => 030070774321090, sensorIDs => 539] in ChangedStatus table.
[Controller]2011-02-06 17:31:02,800 INFO [HTTP-Thread-10] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(107) | DEVICEID:030070774321090	sensorID:[539]statusChangedSensorID:[]Waiting...
[Controller]2011-02-06 17:31:02,928 INFO [HTTP-Thread-7] org.openremote.controller.rest.RoundRobinRESTServlet.doPost(80) | Finished RoundRobin group member REST service.  at 2011-02-06 17:31:02

[Controller]2011-02-06 17:31:03,222 INFO [Thread-8] org.openremote.controller.protocol.telnet.TelnetCommand.readString(349) | received: Internals:
   BTN        03
   DEF        2611 03
   IODev      CUNO1
   NAME       Stalamp_KL
   NR         22
   STATE      on
   TYPE       FS20
   XMIT       2611
   Code:
     1          2611 03
   Readings:
     2011-02-06 17:24:05   state           on
Attributes:
   loglevel   5
   model      fs20di
   room       Huiskamer

It looks like the sensor is found but the " statusChangedSensorID" keeps waiting for a change. I cant relate if the change is made after this line.

I manually switched the Stalamp_KL via telnet to an "on" and "off" state to see if OR would pick up the change and modify the status ID but i didnt. Well out of 20 attempts i saw 1 sensor change. This was only in the logs and not reflected back onto the UI.

 [Controller]2011-02-06 17:41:39,746 INFO [Thread-8] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(327) | send: list Stalamp_KL
[Controller]2011-02-06 17:41:40,118 INFO [HTTP-Thread-5] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(103) | Had timeout for waiting status change.
[Controller]2011-02-06 17:41:40,120 INFO [HTTP-Thread-5] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(109) | Finished polling at 2011-02-06 17:41:40

[Controller]2011-02-06 17:41:40,138 INFO [HTTP-Thread-5] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(79) | Started polling at 2011-02-06 17:41:40
[Controller]2011-02-06 17:41:40,140 INFO [HTTP-Thread-5] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(74) | Querying changed state from ChangedStatus table...
[Controller]2011-02-06 17:41:40,141 INFO [HTTP-Thread-5] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(89) | Found: [device => 030070774321090, sensorIDs => 539] in ChangedStatus table.
[Controller]2011-02-06 17:41:40,141 INFO [HTTP-Thread-5] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(107) | DEVICEID:030070774321090      sensorID:[539]statusChangedSensorID:[]Waiting...

Could you try to test this at your end?

Is there a way to inject a debug line which tells us the current status of the sensor?

Posted by kide at Feb 06, 2011 16:43

Hi Ernst,

I still haven't fully got to grips with the code structure of OR yet and I don't know why you're getting those REST queries and Round Robin activity.

What is your current setup, do you have multiple panels/controllers running?

I do my testing with a very basic setup:

Create a test composer account
Create one device and one command (telnet command - you'll have to manually add the statusFilter and statusFilterGroup properties to the controller.xml after syncing)
Create a new custom sensor (leave State map empty)
Create a basic Android panel (I think you said in another post you're using Android)
Add a label component and set the sensor to the one you just created
Save everything
Run your controller and load in the new controller and panel configuration using the web interface or other means
Connect to your controller from your panel device and hopefully things will be working

Posted by kurrazyman at Feb 06, 2011 19:44

Hi Richard,

The roudrobbin only occurs when the new config has been synced with the online composer and loaded into the android app. Thats the only time i've seen it.

My current setup is only one controller (2 test panels) and 1 device with 3 commands, 1 sensor and 1 switch. More basic than this it doesnt get.

I did as you requested but i still have the same result and the status is not chaging.

To be completely clear i did a fresh checkout with svn to make sure nothing is left behind.

Posted by kide at Feb 06, 2011 21:28

I'm not sure what's going wrong for you Ernst.

I can't test your exact setup as I don't have your telnet server setup, from my experience with the telnet servers I have (I even created a basic telnet server that has no prompt to test the null functionality I added) everything works as expected.

The controller periodically (every 1 second) does a read on all sensors which I believe is working correctly in your case. If you have the ability try switching off your telnet server whilst OR is running and you should see Telnet read errors starting to appear in the window, then restart the telnet server and if the errors stop then your issue isn't with my code changes but something more fundamental I'd say.

If you send me your panel and controller xml files I'll run them my end and see what messages I get.

richarddotturner83atgmaildotcom

Posted by kurrazyman at Feb 06, 2011 21:43

Been following the changes and debate with interest but only had a chance to test myself this evening as I needed the "null" wait aswell (to a Homeseer plugin). Richard - thanks for your efforts so far.

Anyway, I have a couple of sensors updating now.

1 sensor of type Level which returns 0 to 100

1 sensor of Switch which returns "TRUE" or "FALSE"

Labels on the panel update quite happily as I change the state of either, but at the moment I cant get either a slider or switch to update automatically on my panel. Also on the slider on I cant get the set position parameter to be sent properly to a telnet command. Still trying a few things though.

Posted by deanox at Feb 06, 2011 22:44

That's good news Dean,

Glad you've had some success; I have had sliders working without any problem using the usual syntax:

waitForString|command ${param}

Haven't really tested the switches but I know the switch sensor expects an on/off string, what I'm not sure about is whether the sensor tries to convert values to the correct type i.e. TRUE => ON or FALSE => OFF.

I was going to put this logic into the telnet command but not sure this is the right place to deal with it as all protocols need this functionality really.

Keep me posted on your progress!

Posted by kurrazyman at Feb 06, 2011 22:52

What panel are you using - I'm guessing not Android ?

Found http://openremote.org/display/forums/Sliders+on+Androidwhich essenitally describes the same issue. Manually added "min" and "Max" lines to the slider definition in panel.xml and it works. This was regardless of whether the sensor was set to level or range (with 0 to 100 set). So looks like a bug either in the xml generation or android code itself.

Could you check what your panel.xml has for the slider definition ?

Anyway, slider now works with full bi-directional feedback.

Posted by deanox at Feb 06, 2011 23:36

Ok finally we have some (positive) result. The trick was in 2 things

As a test i created everything new with the following controller.xml config. Yes with an error but it worked

   <commands>
    <command id="14" protocol="telnet">
      <property name="port" value="7072" />
      <property name="command" value="null|set Stalamp_KL on" />
      <property name="ipAddress" value="192.168.10.110" />
    </command>
    <command id="15" protocol="telnet">
      <property name="port" value="7072" />
      <property name="command" value="null|set Stalamp_KL off" />
      <property name="ipAddress" value="192.168.10.110" />
    </command>
    <command id="16" protocol="telnet">
      <property name="port" value="7072" />
      <property name="command" value="null|{ $value{Stalamp_KL} }" />
      <property name="ipAddress" value="192.168.10.110" />
    </command>
  </commands>
  <config>

Also i added a  label which would display the status variable of the "custom" sensor with a empty status map.

After running the controller and syncing the panel i saw the following ik the controller.log

 Controller]2011-02-07 07:22:29,589 INFO [Thread-34] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(327) | send: { $value{Stalamp_KL} }
[Controller]2011-02-07 07:22:29,589 INFO [Thread-32] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(327) | send: { $value{Stalamp_KL} }
[Controller]2011-02-07 07:22:30,591 INFO [Thread-34] org.openremote.controller.protocol.telnet.TelnetCommand.readString(349) | received: on

[Controller]2011-02-07 07:22:30,591 INFO [Thread-32] org.openremote.controller.protocol.telnet.TelnetCommand.readString(349) | received: on

[Controller]2011-02-07 07:22:31,096 INFO [Thread-34] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(327) | send: { $value{Stalamp_KL} }
[Controller]2011-02-07 07:22:31,096 INFO [Thread-32] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(327) | send: { $value{Stalamp_KL} }
[Controller]2011-02-07 07:22:32,098 INFO [Thread-32] org.openremote.controller.protocol.telnet.TelnetCommand.readString(349) | received: off

[Controller]2011-02-07 07:22:32,098 INFO [Thread-34] org.openremote.controller.protocol.telnet.TelnetCommand.readString(349) | received: off

[Controller]2011-02-07 07:22:32,098 INFO [HTTP-Thread-1] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(121) | Had waited the skipped sensor ids of statuses in DEVICEID:030070774321090	sensorID:[12, 13]statusChangedSensorID:[12]
[Controller]2011-02-07 07:22:32,100 INFO [HTTP-Thread-1] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedStatusesFromCachedStatusTable(134) | Querying changed data from StatusCache...
[Controller]2011-02-07 07:22:32,100 INFO [HTTP-Thread-1] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedStatusesFromCachedStatusTable(138) | Have queried changed data from StatusCache.
[Controller]2011-02-07 07:22:32,101 INFO [HTTP-Thread-1] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(105) | Return the polling status.
[Controller]2011-02-07 07:22:32,102 INFO [HTTP-Thread-1] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(109) | Finished polling at 2011-02-07 07:22:32

[Controller]2011-02-07 07:22:32,138 INFO [HTTP-Thread-1] org.openremote.controller.rest.StatusPollingRESTServlet.doPost(79) | Started polling at 2011-02-07 07:22:32
[Controller]2011-02-07 07:22:32,139 INFO [HTTP-Thread-1] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(74) | Querying changed state from ChangedStatus table...
[Controller]2011-02-07 07:22:32,140 INFO [HTTP-Thread-1] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(89) | Found: [device => 030070774321090, sensorIDs => 12,13] in ChangedStatus table.
[Controller]2011-02-07 07:22:32,140 INFO [HTTP-Thread-1] org.openremote.controller.service.impl.StatusPollingServiceImpl.queryChangedState(107) | DEVICEID:030070774321090	sensorID:[12, 13]statusChangedSensorID:[]Waiting...
[Controller]2011-02-07 07:22:32,601 INFO [Thread-34] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(327) | send: { $value{Stalamp_KL} }
[Controller]2011-02-07 07:22:32,601 INFO [Thread-32] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(327) | send: { $value{Stalamp_KL} }
[Controller]2011-02-07 07:22:33,603 INFO [Thread-34] org.openremote.controller.protocol.telnet.TelnetCommand.readString(349) | received: off

[Controller]2011-02-07 07:22:33,603 INFO [Thread-32] org.openremote.controller.protocol.telnet.TelnetCommand.readString(349) | received: off

Yes! the status was updating and i could see the change reflecting in the label which was now telling me "off"

So that is some good progress here. On the other hand i also added a button and a switch sensor and they stayed both in the OFF state even if a manually switched the lamp to ON.

I modified the controller.xml so it would use the regex filter like:

   <commands>^M
    <command id="14" protocol="telnet">^M
      <property name="port" value="7072" />^M
      <property name="command" value="null|set Stalamp_KL on" />^M
      <property name="ipAddress" value="192.168.10.110" />^M
    </command>^M
    <command id="15" protocol="telnet">
      <property name="port" value="7072" />
      <property name="command" value="null|set Stalamp_KL off" />
      <property name="ipAddress" value="192.168.10.110" />
    </command>
    <command id="16" protocol="telnet">
      <property name="port" value="7072" />
      <property name="command" value="null|list Stalamp_KL" />
      <property name="ipAddress" value="192.168.10.110" />
      <property name="statusFilter" value="^(?i)(?s)(?m).*state\s+(\w+).*$" />
      <property name="statusFilterGroup" value="1" />
      <property name="statusDefault" value="0" />
    </command>

After running the controller.log showed:

\[Controller\]2011-02-07 07:46:49,887 INFO \[Thread-8\] org.openremote.controller.protocol.telnet.TelnetCommand.sendString(327) \| send: list Stalamp_KL
\[Controller\]2011-02-07 07:46:50,903 INFO \[Thread-8\] org.openremote.controller.protocol.telnet.TelnetCommand.readString(349) \| received: Internals:
&nbsp;&nbsp; BTN&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 03
&nbsp;&nbsp; DEF&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2611 03
&nbsp;&nbsp; IODev&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CUNO1
&nbsp;&nbsp; NAME&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stalamp_KL
&nbsp;&nbsp; NR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 22
&nbsp;&nbsp; STATE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; off
&nbsp;&nbsp; TYPE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FS20
&nbsp;&nbsp; XMIT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2611
&nbsp;&nbsp; Code:
&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2611 03
&nbsp;&nbsp; Readings:
&nbsp;&nbsp;&nbsp;&nbsp; 2011-02-07 07:41:57&nbsp;&nbsp; state&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; off
Attributes:
&nbsp;&nbsp; loglevel&nbsp;&nbsp; 5
&nbsp;&nbsp; model&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fs20di
&nbsp;&nbsp; room&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Huiskamer

And also the label is now showing the correct status. Also after a manual change it is  picked up and processed.

The only weird thing is that in the 1st setup you see a recieved line like:

 [Controller]2011-02-07 07:22:33,603 INFO [Thread-34] org.openremote.controller.protocol.telnet.TelnetCommand.readString(349) | received: off

Which is not there in the second setup. Maybe you could filter out the complete input and only show the lines that are relavant? its more cosmetic and not nessecary at this moment.

Conclusion:

Richard your code works splendid and thank you for that. The updating of other relevant sensors in and button states is buggy which we should report to Juha or Marc probably?

Do you have anything more you would like me to test with?

Posted by kide at Feb 07, 2011 06:54

after playing around i found the following very interesting:

i sayed in a previous post "So that is some good progress here. On the other hand i also added a button and a switch sensor and they stayed both in the OFF state even if a manually switched the lamp to ON."

This does not seem to be true.

If you add a switch in the designer and you do NOT use ON/OFF pictures the state of the button wil allways stay in OFF.

When you use ON/OFF pictures it switches when the state switches! so its a little bug here.

Posted by kide at Feb 07, 2011 06:54

Dean,

I have been using an Android panel and sliders were working for me fine without the need to manually change the panel.xml; in the post you have linked to above I noticed Juha was able to fix the issue with the persons composer account so to me it seems like an issue that doesn't affect everyone.

Posted by kurrazyman at Feb 07, 2011 07:43

Ernst,

Glad you've finally got things working.

As you say there appears to be some bugs in a few of the button component which need to be raised and fixed.

Posted by kurrazyman at Feb 07, 2011 07:47

albeit on a slightly selfish level as I have a new house build underway at the moment and I need a Home Automation Control System that can integrate the various automation/AV elements together and I think OpenRemote is a good base to work from.

Selfish motives are completely acceptable and expected. I can speak for myself and the rest of the community when I say thank you for contributing your effort back to Open Source for everyone else to try and use as well. That's how we build this thing to address the automation needs without getting locked in to horribly over-priced, proprietary solutions.

There's some notes in the KNXConnnectionBuilder.java file discussing this sort of issue and I'm looking to implement a connection manager for the telnet protocol also, can't help thinking that a generic solution would be best here for all current and future protocols; what are your thoughts/plans on this?

I assume the case here are implementations on telnetd side that only allow one concurrent connection?

On one hand I view these as exception cases (both for KNX and Telnet) as I would think in normal circumstances concurrency should not be something that the telnetd cannot handle.

However, when such limitation exists, connection manager/pooling is an appropriate solution.

Partly this is in Java through JCA but I haven't wanted to pull everything that's involved with that into the controller yet. At the moment am trying to limit 3rd party dependencies to make the controller more portable and available to smaller (lower cost BOM) systems.

However, if there's a low cost JCA implementation we should look at, then I'm open to evaluating it.

Barring that, we could pull generic connection management implementation for all protocols to re-use. What the right abstractions are exactly I haven't thought about yet. It may make sense to implement a duplicate for your telnet protocol implementation first and then we compare it with KNX one and extract and abstract the commonalities. Or simply building connection mgr classes to delegate to at this point from the implementation and we later pull them up to controller level is an option.

Posted by juha at Feb 07, 2011 08:00

as i mailed you i've reported the bugs to Juha and l hope it will be fixed soon.

Question: could you modify the status polling interval to something else than 1 sec or is it outside your working space.

Posted by kide at Feb 07, 2011 08:11

The status polling interval is controlled by the PollingMachineThread.java and I don't think it's customisable at present but have a look.

Posted by kurrazyman at Feb 07, 2011 08:41

One way to deal with this is not to react to every read request coming from the controller (throttle it) – will be done for KNX as well and I think Eric did the same for Lutron.

I.e. you can disconnect the polling from controller which is saying it can deal with/wants events every n seconds to a reduced number of requests when you actually go to the device (and you can cache device status as well).

This could naturally fit into your connection manager functionality. And something we may eventually want to abstract out into the controller so it is reusable across several protocol implementations.

Posted by juha at Feb 07, 2011 08:59

Richard / Juha
I've started work on implementing (copying) Richards work to the Socket Protocol.
A while back I provided a patch to use Regex to remove the Non-ASCII values, but this approach seems to be much more flexible.
So far I've been able to implement a slider for Onkyo Amp Vol using IP <-> RS232 GC-100 Gateway and it works very well.
I am getting some NullPointer exceptions in the controller for Sensors, but haven't investigated that yet, it works though with little effort. (I suspect the errors are for commands that I didn't update to the new structure.)
All credit should go to Richard since I'm only CPing his work.
BTW. I have no idea how to create a branch in the SVN let alone actually upload something there. The original patch to me long enough to figure out how to do, but if either of you are interested I guess I can provide another patch. (have to remember how)
Phill.

Posted by flipit at May 24, 2011 08:33

Hi Phill,

Well done for contributing, copying or not any contribution that builds on existing code is how things progress...all I did was add to someone else's code for this telnet enhancement.

I'm sure if you email Juha with your additions to the socket protocol he'd be very grateful and could add it to the repo for everyone's benefit.

Rich

Posted by kurrazyman at May 24, 2011 20:50

Hello Phillip,

Let me know if you need help with this (or if I lost your email?)

– Juha

Posted by admin at Jun 12, 2011 10:33

Hi Richard
I went to update my work on the Socket protocol and provide a valid patch to Juha (Juha I did send you what I had so far). It looks like the feature branch has gone, or been folded into another branch.
Any chance you could update the link at the top of the post. (http://openremote.svn.sourceforge.net/svnroot/openremote/branches/feature/Controller_2_0_0_Alpha11_telnet/)
Many Thanks
Phill

Posted by flipit at Jun 23, 2011 16:31

Found it. It merged with the trunk.. All good.

Posted by flipit at Jun 24, 2011 10:47
Document generated by Confluence on Jun 05, 2016 09:32