Rule Variables are not submitted to an item to execute

Tags: #<Tag:0x00007f386f04cbb8>

I have a problem with a rule, which is to control a lamp by a voice control. The voice control gives out a JSON array, so I added a log output to my rule to see if all parameters are given right. All of it is correct, but inside the “Then” part, it should control the lamp wtih the read-out parameters, but there is no action inside my log for the lamp.

so here is the rule:

rule “VIC”
Item LivingRoom_Sprachsteuerung received update

logInfo("Sprachsteuerung steuert Gerät: ", LivingRoom_Sprachsteuerung_intent.state.toString)

var Number intentValue = transform(“JSONPATH”, “$.content.slots.[0].value”, LivingRoom_Sprachsteuerung_dimmer.state.toString)

var String pureIntent = transform(“JSONPATH”, “$.content.intent”, LivingRoom_Sprachsteuerung_intent.state.toString)

var String device_val = transform(“JSONPATH”, “$.content.slots.[0].name”, LivingRoom_Sprachsteuerung_name.state.toString)

logInfo("Welcher Wert: ", device_val)
logInfo("Wert: ", intentValue)
logInfo("Snips device value: ", pureIntent)

if (pureIntent = “lampe”) {
sendCommand(LivingRoom_Ecklampe_Color, intentValue)
} else if (pureIntent = “stehlampe”) {
LivingRoom_Stehlampe_Color = sendCommand(intentValue)

if (device_val = “helligkeit”) {
sendCommand(LivingRoom_Ecklampe_Dimmer, intentValue)

and the only thing inside my Log Viewer is this, but no control happens:

Maybe someone can help me, what is wrong in here.

This line appears to be a nonsense, but it is not the immediate problem.

It is common advice to use the method for myItem.sendCommand, rather than the action sendCommand(myItem, cmd), because it is better at doing any needed conversions between command parameter and target Item.
So I’d do that
LivingRoom_Ecklampe_Color.sendCommand( intentValue )

But really

That is not an equality test, it’s an assignment, a make-equal-to.
if (pureIntent == “lampe”) {
Easy mistake to make and overlook, you will do it lots more before remembering to look for it when something unexpected happens.

Thanks rossko57, I’ve updated all of the mistakes and also changed the action to method, as you recommended. Really a bad fault with the equality test, I also changed it, but now I have the probem, that OH cannot invoke the method. This is in my log now:

So I suppose, here´s something else still wrong with it. The item to control is a philips hue lamp, if this helps.

It could have something to do with the value being over 100 if you use a dimmer item as those only accept 0-100 as commands. But it would still be really helpful if you could post your new rewritten rule for us.

Yes, of course. Here is the corrected version:

You are still using the action instead of the method for your helligkeit in the rule.
Edit: I found the part relevant in the documentation. The general action only accepts strings as arguments.

1 Like