This page last changed on Apr 09, 2013 by juha.

Hi,

I am using Domotiga and am not happy with the clients available so I am looking into Openremote for controlling my lights, alarm, heating and home theatre.

I have three commands; On, Off and Status. I am using the Domotiga XML-RPC interface.

This is how these look in controller.xml:

    <command id="391" protocol="http">
      <property name="workload" value="&lt;methodCall&gt;&lt;methodName&gt;device.getstate&lt;/methodName&gt;&lt;params&gt;&lt;param&gt;&lt;value&gt;Serre Spots&lt;/value&gt;&lt;/param&gt;&lt;/params&gt;&lt;/methodCall&gt;" />
      <property name="pollingInterval" value="1s" />
      <property name="method" value="POST" />
      <property name="url" value="http://192.168.1.109:9009" />
      <property name="xpath" value="//string" />
      <property name="name" value="Serre Spots Status" />
    </command>
    <command id="392" protocol="http">
      <property name="workload" value="&lt;methodCall&gt;&lt;methodName&gt;device.setdevice&lt;/methodName&gt;&lt;params&gt;&lt;param&gt;&lt;value&gt;Serre Spots&lt;/value&gt;&lt;/param&gt;&lt;param&gt;&lt;value&gt;Off&lt;/value&gt;&lt;/param&gt;&lt;/params&gt;&lt;/methodCall&gt;" />
      <property name="method" value="POST" />
      <property name="url" value="http://192.168.1.109:9009/" />
      <property name="name" value="Serre Spots (OFF)" />
    </command>
    <command id="393" protocol="http">
      <property name="workload" value="&lt;methodCall&gt;&lt;methodName&gt;device.setdevice&lt;/methodName&gt;&lt;params&gt;&lt;param&gt;&lt;value&gt;Serre Spots&lt;/value&gt;&lt;/param&gt;&lt;param&gt;&lt;value&gt;On&lt;/value&gt;&lt;/param&gt;&lt;/params&gt;&lt;/methodCall&gt;" />
      <property name="method" value="POST" />
      <property name="url" value="http://192.168.1.109:9009/" />
      <property name="name" value="Serre Spots (ON)" />
    </command>

When I look at the log I see this for the status command:

ERROR [Polling thread for sensor: Serre Spots]: HttpGetCommand could not execute
org.apache.http.client.HttpResponseException: Method Not Allowed
    at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:67)
    at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:54)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:735)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:709)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:700)
    at org.openremote.controller.protocol.http.HttpGetCommand.requestURL(HttpGetCommand.java:176)
    at org.openremote.controller.protocol.http.HttpGetCommand.run(HttpGetCommand.java:190)
    at java.lang.Thread.run(Thread.java:722)
[Fatal Error] :1:1: Premature end of file.
ERROR [Polling thread for sensor: Serre Spots]: Could not perform xpath evaluation
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:251)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:300)
    at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
    at org.openremote.controller.protocol.http.HttpGetCommand.run(HttpGetCommand.java:210)
    at java.lang.Thread.run(Thread.java:722)

The fatal error makes sense as there is no data returned.

And this when pushing the switch:

ERROR [HTTP-Thread-2]: HttpGetCommand could not execute
org.apache.http.client.HttpResponseException: Method Not Allowed
    at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:67)
    at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:54)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:735)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:709)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:700)
    at org.openremote.controller.protocol.http.HttpGetCommand.requestURL(HttpGetCommand.java:176)
    at org.openremote.controller.protocol.http.HttpGetCommand.send(HttpGetCommand.java:136)
    at org.openremote.controller.service.impl.ControlCommandServiceImpl.trigger(ControlCommandServiceImpl.java:95)
    at org.openremote.controller.rest.ControlCommandRESTServlet.handleRequest(ControlCommandRESTServlet.java:77)
    at org.openremote.controller.rest.RESTAPI.doPost(RESTAPI.java:125)
    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:63)
    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.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)

Am I missing something here? Can someone point me in the right direction?

I am using the latest OpenRemote controller: 2.0.2.

Thanks,
Sander

Can you try the OpenRemote-Controller-2.1.0_Alpha-SNAPSHOT-2013-04-09.zip? There's some code that looks suspicious in the HTTP implementation of 2.0.2 and this seems to have been modified in the 2.1.0 alpha.

Posted by juha at Apr 09, 2013 19:14

Thanks, that solved it!
Now I am looking at the Unsupported Media Type exception ..... HTTP 100 is not understood by Domotiga.

Hmm, guess I have to write something myself to give back the status to Openremote.

Posted by sandervp at Apr 09, 2013 21:59

For the Unsupported Media Type a fix is available. Checke here: http://www.openremote.org/display/forums/Controlling+XBMC+with+json-rpc
The 2.1_Alpha might already include this fix but the designer does not have a field to enter the attribute for the command.
You can edit the controller.xml manually and add this line to your http commands:

 <property name="contentType" value="application/json" />
Posted by mredeker at Apr 10, 2013 08:42

Ok, I copied the class files and added

<property name="contentType" value="application/json" />

With this as the result:

ERROR [Polling thread for sensor: Serre Spots]: ClientProtocolException when executing HTTP method
org.apache.http.client.HttpResponseException: Unsupported Media Type
	at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:67)
	at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:54)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:735)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:709)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:700)
	at org.openremote.controller.protocol.http.HttpGetCommand.requestURL(HttpGetCommand.java:231)
	at org.openremote.controller.protocol.http.HttpGetCommand.run(HttpGetCommand.java:245)
	at java.lang.Thread.run(Thread.java:722)
[Fatal Error] :1:1: Premature end of file.
ERROR [Polling thread for sensor: Serre Spots]: Could not perform xpath evaluation
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:251)
	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:300)
	at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
	at org.openremote.controller.protocol.http.HttpGetCommand.run(HttpGetCommand.java:267)
	at java.lang.Thread.run(Thread.java:722)

As I am using XMLRPC this it should use

<property name="contentType" value="text/xml" />

The result of that is:

ERROR [Polling thread for sensor: Serre Spots]: ClientProtocolException when executing HTTP method
org.apache.http.client.HttpResponseException: Bad Request
	at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:67)
	at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:54)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:735)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:709)
	at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:700)
	at org.openremote.controller.protocol.http.HttpGetCommand.requestURL(HttpGetCommand.java:231)
	at org.openremote.controller.protocol.http.HttpGetCommand.run(HttpGetCommand.java:245)
	at java.lang.Thread.run(Thread.java:722)
[Fatal Error] :1:1: Premature end of file.
ERROR [Polling thread for sensor: Serre Spots]: Could not perform xpath evaluation
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:251)
	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:300)
	at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
	at org.openremote.controller.protocol.http.HttpGetCommand.run(HttpGetCommand.java:267)
	at java.lang.Thread.run(Thread.java:722)

Did I miss something?

Posted by sandervp at Apr 10, 2013 19:31

This was talked about here: http://www.openremote.org/display/forums/Controlling+XBMC+with+json-rpc?focusedCommentId=20452698#comment-20452698
It's a Domotiga issue not following the HTTP specs.

Posted by mredeker at Apr 10, 2013 20:12

I was aware of that .... but was hoping something had changed on the Gambas side.
Submitted a bug for this: https://code.google.com/p/gambas/issues/detail?id=419

Posted by sandervp at Apr 10, 2013 21:37

I realized the easiest way to get rid of the Expect: 100-continue header was to put a proxy in between and strip the header .... works like a charm

Posted by sandervp at Apr 12, 2013 19:53
Document generated by Confluence on Jun 05, 2016 09:41