This page last changed on Mar 04, 2014 by juha.

Hi,

I would like to send a HTTP POST command with a variable but I get the error:

ERROR [Polling thread for sensor: T1_Sensor_Range]: ClientProtocolException when executing HTTP method
org.apache.http.client.HttpResponseException: Internal Server Error
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.send(HttpGetCommand.java:162)
at org.openremote.controller.model.Command.execute(Command.java:230)
at org.openremote.controller.statuscache.CommandFacade.command(CommandFacade.java:85)
at org.openremote.controller.protocol.Rule_Graph_0.defaultConsequence(Rule_Graph_0.java:8)
at org.openremote.controller.protocol.Rule_Graph_0DefaultConsequenceInvoker.evaluate(Rule_Graph_0DefaultConsequenceInvoker.java:30)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1071)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:785)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:751)
at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at org.openremote.controller.statuscache.rules.RuleEngine.push(RuleEngine.java:177)
at org.openremote.controller.statuscache.EventProcessorChain.push(EventProcessorChain.java:188)
at org.openremote.controller.statuscache.StatusCache.update(StatusCache.java:260)
at org.openremote.controller.model.sensor.Sensor.update(Sensor.java:342)
at org.openremote.controller.protocol.http.HttpGetCommand.run(HttpGetCommand.java:274)
at java.lang.Thread.run(Thread.java:662)

Rules load the command value in a variable like:

package org.openremote.controller.protocol
global org.openremote.controller.statuscache.CommandFacade execute;
import org.openremote.controller.protocol.Event;
rule "Graph"
when
$data : Event ( source == "T1_Sensor_Range" )
then
System.out.println ($data.getValue());
execute.command ("Graph_PAPP_Cde", $data.toString());
end

And this is a part of my Controller.xml

Thank you to help me.


Controller.png (image/png)
Controller2.png (image/png)
Controller.png (image/png)

execute.command ("Graph_PAPP_Cde", $data.toString());

Try to change it to:

execute.command ("Graph_PAPP_Cde", $data.getValue().toString());
Posted by aktur at Feb 23, 2014 19:38

Michal,

I get exactely the same error with the command:

execute.command ("Graph_PAPP_Cde", $data.getValue().toString());

Posted by frank77 at Feb 24, 2014 07:11

"Internal Server Error" indicates an error on the server side. The HTTP request goes through but the server fails and returns a 500 error.

Posted by ebariaux at Feb 24, 2014 08:45

Yes the HTTP server don't anderstand the variable $data. If I replace the variable by a fixe number like "200", I don't have error?

Posted by frank77 at Feb 24, 2014 12:19

Try to put in your HTTP command definition ${param} instead of $data

Posted by aktur at Feb 24, 2014 12:38

it works.

I put ${param} in workloard instead $data and I send my variable.

Thanks a lot Michal and Eric

Posted by frank77 at Feb 24, 2014 13:22

Hi I am trying to get my Sonos to announce the time in the morning - but I am not clear on the how you got this to work.

I have an http command to get my Sonos to say something:

http://192.168.0.3:5005/Living Room/say/

As a test I want to append a variable from a datetime sensor source = "minute"

In designer I have added a workload

 ${param} 

Then in rules I have tried

rule "Time Say"
timer(int: 30s 30s)
when
  $b1 : Event(source=="minute")
   	then
   execute.command("SONOS SAY TIME", $b1.getValue());
end

But this falls over when I try and run it any idea what I'm doing wrong?

Thanks

Posted by jules_bike at Jan 29, 2015 22:25
Document generated by Confluence on Jun 05, 2016 09:38