[SOLVED] Error: Couldn't invoke 'assignValueTo' for feature JvmVoid: for sendHttpPostRequest

  • Platform information:
    • Hardware: Running in a LXC Container on a Dell R510 Server
    • OS: Debian 9 (Stretch)
    • Java Runtime Environment: openjdk 1.8.0_181
    • openHAB version: OpenHAB2 2.3.0-1
  • Issue of the topic:

I have some rules setup to interface with my Radio Thermostat CT50. Right now both the “Set Fan” buttons work. However, they throw an error in the openhab.log.

ERROR

2018-11-18 20:36:05.303 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Set Fan': An error occurred during the script execution: Couldn't invoke 'assignValueTo' for feature JvmVoid:  (eProxyURI: ct50dn.rules#|::0.2.3.2.0.1::0::/1)

RULE

rule "Set Fan"
when
    Item HVAC_CT50Dn_FanMode received command
then
    logInfo("HVAC", "HVAC_CT50Dn_FanMode received: " + receivedCommand)
    output = sendHttpPostRequest("http://172.27.4.2/tstat/fmode", "application/json", '{"fmode":' + receivedCommand + '}')
    logInfo("HVAC", "HVAC Command sent - output: " + output)
end

Can anyone help?

Thanks,
begleysm

No idea if this is correct, but where does the value of receivedCommand come from?

var output =

or

val output =
2 Likes

try defining the String val/var output

rule "Set Fan"
when
	Item HVAC_CT50Dn_FanMode received command
then
	logInfo("HVAC", "HVAC_CT50Dn_FanMode received: " + receivedCommand)
	val String URL = "http://172.27.4.2/tstat/fmode"
	var String contenttype = "application/json"
	var String jsondata = '{"fmode":' + receivedCommand + '}'
	val String output = sendHttpPostRequest(URL, contenttype, jsondata)
	logInfo("HVAC", "HVAC Command sent - output: " + output)
end

From the triggering Item (HVAC_CT50Dn_FanMode)

Ps: @begleysm Use VS Code… it helps alot !

1 Like

The variable is just created with no reference I would have expected something more like:

   ` HVAC_CT50Dn_FanMode.receivedC`ommand 

Ira

I see your point, but the rules engine “knows” which Item triggered the rule and with which Command value.

See more here: Features for Rules that work with Groups

There are a number of implicit variables that are made available in a Rule based on how the Rule was triggered. Most of them are documented here. The missing one is now which gives you a DateTime object for right now that you can manipulate (e.g. schedule a Timer for five seconds from now using now.plusSeconds(5).

Now to address your expectation, there are few reasons why it doesn’t work like that.

  • As Dim posted, the Rule gets triggered on a command BEFORE the Item actually changes state. So, depending on timing, HVAC_CT50_Dn_FanMode.state may still be at the old state inside the Rule for a few dozen milliseconds.

  • What happens if the Rule can be triggered by a whole bunch of Items receiving a command? How do you know that the receivedCommand is? It would be pretty ugly to have to iterate over all of the Items and call receivedCommand on each one until you find one that has that set. And then what if another Item received a command in the mean time while you were searching? Then you won’t know which one was the command that actually triggered the Rule.

So OH provides this and a set of other similar implicit variables to the Rule when it executes.

1 Like

Thanks @pacive, that did the trick. For others reading this, both “val” and “var” solved the problem.

Hi begleysm,
What did your final rule look like?

@wjm here is the rule I ended up with

rule "Set Fan"
when
    Item HVAC_CT50Dn_FanMode received command
then
    logInfo("HVAC", "HVAC_CT50Dn_FanMode received: " + receivedCommand)
    val output = sendHttpPostRequest("http://RA-CT50-Dn/tstat/fmode", "application/json", '{"fmode":' + receivedCommand + '}')
    logInfo("HVAC", "HVAC Command sent - output: " + output)
end