[SOLVED] Received Command on Group Item incinsistent


I want to act on a group item depending on the received command of a group of Rollershutter Item.


Group gBlindPositions
Rollershutter Shutter_GF_Test       "Test"                                      <bblind> (gShutters)
Dimmer Shutter_GF_Test_Position     "Test Positon [%i%]"                        <bblind> (gBlindPositions)


val logName = "Blinds_Pos ==========="

rule "Update Blinds Position"
    Member of gShutters received command 
	logInfo(logName, "A member of gShutters received a command: " + triggeringItem.name + ", state=" + triggeringItem.state)

    val positionName = triggeringItem.name + "_Position)"
    val positionItem = gBlindPositions.members.findFirst[ t | t.name == positionName ]

    val lastUpdateTime = triggeringItem.lastUpdate
    val deltaT = (now.millis - triggeringItem.lastUpdate.millis) / 1000

    logInfo(logName,"Blind {} run from {} to {} for {} seconds", triggeringItem.name, lastUpdateTime, now, deltaT)

On Karaf I send the bellow. I wait a few seconds between the two commands below:

openhab> smarthome:send Shutter_GF_Essen UP
openhab> smarthome:send Shutter_GF_Essen STOP

I expect to see the received command UP in the rule, but I get this in karaf, log:tail

23:03:44.520 [INFO ] [smarthome.event.ItemCommandEvent     ] - Item 'Shutter_GF_Test' received command STOP
23:03:44.542 [INFO ] [e.model.script.Blinds_Pos ===========] - A member of gShutters received a command: Shutter_GF_Test, state=0
23:03:44.598 [INFO ] [e.model.script.Blinds_Pos ===========] - Blind Shutter_GF_Test run from 2019-02-04T23:03:41.668+01:00 to 2019-02-04T23:03:44.596+01:00 for 2 seconds

First log entry shows STOP was received, but in the the triggeringItem.state is set to “0”. Is there a chance to get the received command “STOP/UP/DOWN” instead of 0/100 in the rule to act on it.

Something like triggeringItem.receivedCommand? I want the received command and not the state it is in after receiving the command.


Sending a command to an Item may never cause any state change at all.
In most cases, openHAB’s autoupdate feature will have been left enabled by default on the Item. In which case, autoupdate will guess at the command’s effect on the Item and issue an update. That takes a finite time.
In other cases, the command may be sent to real device, and eventually a response may come back causing an update.

The upshot is, in a rule triggered by command, never expect the command to have been actioned yet and had any effect on state.

You can just use receivedCommand

This was the missing piece. Thanks!


for what reason are you using those lines:

val positionName = triggeringItem.name + “_Position)”
val positionItem = gBlindPositions.members.findFirst[ t | t.name == positionName ]

I get a log entry:

Validation issues found in configuration model ‘rollershutter_state.rules’, using it anyway:
The value of the local variable positionItem is not used

Could you explain please what is it good for? Thx in advance.