[SOLVED] Hab panel multi selection widget: only first selection works with rule?

I had a similar problem in my ECMA rule. In my rule there were several cases and a default case, the code in the dfault was used all the time.
Try it with such:

switch (receivedCommand.toString)

Thanks for the idea, but same behaviour :frowning:

I have no idea anymore for now why this is not working

2021-01-23 13:32:52.356 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'AllLightsSwitchGroupAmbient' changed from  WOHNZIMMER to ON

2021-01-23 13:32:54.948 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'AllLightsSwitchGroupAmbient' received command  WOHNZIMMER

2021-01-23 13:32:54.951 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'AllLightsSwitchGroupAmbient' changed from ON to  WOHNZIMMER`

SceneGroup does not get triggered at all here.

Use some logInfo lines in order to show where the code really goes to,

Make sure you have only one rule in any file named “scene”.

Same result unfortunetely although I did have a block commented out rule named scene but I copied to another file to be sure. Same result.

I’d do the following:
-create a default case
-use a a logInfo statement in each case,
-log the String-value of receivedCommand.
That way you should get hints where the problem is.

1 Like

The values do match:

I am picking Wohnzimmer in Habpanel widget as well as the correct SceneGroup value is here:

2021-01-23 16:55:14.315 [INFO ] [nhab.core.model.script.myRule-after1] - value is uPJnmIlnGampnc9

2021-01-23 16:55:14.318 [INFO ] [nhab.core.model.script.myRule-after2] - value is  WOHNZIMMER

==> /var/log/openhab/events.log <==

2021-01-23 16:55:14.014 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'AllLightsSwitchGroupAmbient' received command  WOHNZIMMER

rule "scene"

when

Item AllLightsSwitchGroupAmbient received command

then

switch (receivedCommand.toString)

{

case "WOHNZIMMER" : sendCommand(WohnzimmerSceneGroup,"uPJnmIlnGampnc9")

}

logInfo("myRule-after1", "value is {}", WohnzimmerSceneGroup.state)

logInfo("myRule-after2", "value is {}", AllLightsSwitchGroupAmbient.state)

end

Ok, receivedCommand seems to be a problem?

rule "scene"

when

Item AllLightsSwitchGroupAmbient received command

then

switch (receivedCommand.toString)

{

case "WOHNZIMMER" : sendCommand(WohnzimmerSceneGroup,"uPJnmIlnGampnc9")

}

logInfo("myRule-after1", "value is {}", WohnzimmerSceneGroup.state)

logInfo("myRule-after2", "value is {}", AllLightsSwitchGroupAmbient.state)

logInfo("myRule-after3", "value is {}", receivedCommand.state)

end


2021-01-23 16:57:53.669 [INFO ] [nhab.core.model.script.myRule-after1] - value is uPJnmIlnGampnc9

2021-01-23 16:57:53.672 [INFO ] [nhab.core.model.script.myRule-after2] - value is  WOHNZIMMER

2021-01-23 16:57:53.678 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'test-1' failed: 'state' is not a member of 'org.openhab.core.types.Command'; line 12, column 41, length 21 in test

receivedCommand.toString not .state!

Ah sorry, the loginfo on receivedCommand is not a state I guess:

==> /var/log/openhab/openhab.log <==

2021-01-23 16:59:46.330 [INFO ] [nhab.core.model.script.myRule-after1] - value is uPJnmIlnGampnc9

2021-01-23 16:59:46.333 [INFO ] [nhab.core.model.script.myRule-after2] - value is  WOHNZIMMER

2021-01-23 16:59:46.336 [INFO ] [nhab.core.model.script.myRule-after3] - value is  WOHNZIMMER
rule "scene"

when

Item AllLightsSwitchGroupAmbient received command

then

switch (receivedCommand.toString)

{

case "WOHNZIMMER" : sendCommand(WohnzimmerSceneGroup,"uPJnmIlnGampnc9")

}

logInfo("myRule-after1", "value is {}", WohnzimmerSceneGroup.state)

logInfo("myRule-after2", "value is {}", AllLightsSwitchGroupAmbient.state)

logInfo("myRule-after3", "value is {}", receivedCommand.state.toString)

end

2021-01-23 17:01:27.854 [INFO ] [nhab.core.model.script.myRule-after1] - value is uPJnmIlnGampnc9

2021-01-23 17:01:27.857 [INFO ] [nhab.core.model.script.myRule-after2] - value is WOHNZIMMER

2021-01-23 17:01:27.860 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘test-1’ failed: ‘state’ is not a member of ‘org.openhab.core.types.Command’; line 12, column 41, length 21 in test

==> /var/log/openhab/events.log <==

2021-01-23 17:01:27.848 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘AllLightsSwitchGroupAmbient’ received command WOHNZIMMER

Still state seems to be a problem here right?

receivedCommand is a variable not an item, so no state!

Are you sure the sendCommand is not performed? The WohnzimmerSceneGroup shows the desired value if I’m not mistaken.

Yeah that’s what I mean, the value(s) seem to be correct but it just does not execute the sendCommand from the switch case. When I deploy a test button in habpanel with the SceneGroup value as a switch, it does fire. Any ideas?

For one, I would not be sure if the sendCommand is performed or not if you have no logInfo in this case and if the scene is already in the desired state.
If the above doesn’t show any difference I’m out off clues for the moment as well.

1 Like

Yeah I can confirm that the scene is not in the desired state before.

So current ruleset is this:

rule "scene"

when

Item AllLightsSwitchGroupAmbient received command

then

switch (receivedCommand.toString)

{

case "WOHNZIMMER" : sendCommand(WohnzimmerSceneGroup,"uPJnmIlnGampnc9")

}

logInfo("myRule-after1", "value is {}", WohnzimmerSceneGroup.state)

logInfo("myRule-after2", "value is {}", AllLightsSwitchGroupAmbient.state)

logInfo("myRule-after3", "value is {}", receivedCommand.toString)

end

Log Viewer:

2021-01-23 17:18:23.774 [INFO ] [nhab.core.model.script.myRule-after1] - value is uPJnmIlnGampnc9

2021-01-23 17:18:23.776 [INFO ] [nhab.core.model.script.myRule-after2] - value is  WOHNZIMMER

2021-01-23 17:18:23.781 [INFO ] [nhab.core.model.script.myRule-after3] - value is  WOHNZIMMER

==> /var/log/openhab/events.log <==

2021-01-23 17:18:23.770 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'AllLightsSwitchGroupAmbient' received command  WOHNZIMMER

@rossko57 Any ideas left maybe?
I have two use cases where I want to control multiple items from the selection widget in habpanel.
If there is no solution I would need to deploy 15x Buttons instead of 2 selection widgets where I can pick different items and their desired states.

Is there any alternative? I still think some bogus thing I dont see atm :slight_smile:

Your actual code WITHOUT a logInfo in case of “WOHNZIMMER” does not tell whether the code went into the case.

I found the goddamn problem :slight_smile:

The rule as expected is fine but habpanel is the problem.
The WOHNZIMMER case was the 4th item in the selection widget list, I have retried with a TEST case and no other cases to select in the widget.

Turns out only the first entry of the selection widget is executed but not any other after that, meaning the second entry for example with a second case in the rule is not executed. Any ideas?

rule "scene"

when

Item AllLightsSwitchGroupAmbient received command

then

switch (receivedCommand.toString)

{

case "WOHNZIMMER" : WohnzimmerSceneGroup.sendCommand("uPJnmIlnGampnc9")

case "OFFICE" : OfficeSceneGroup.sendCommand("wld0q4iKiCQNo46")

}

logInfo("myRule-after1", "value is {}", WohnzimmerSceneGroup.state)

logInfo("myRule-after2", "value is {}", AllLightsSwitchGroupAmbient.state)

logInfo("myRule-after3", "value is {}", receivedCommand.toString)

end

Any ideas why the second one is not working from the selection? I thought it is just comma seperated with the cases from the rule right? In this above example WOHNZIMMER works as expected but OFFICE throws the same behaviour, command does not get fired.