Beginners question on rules

Hi there,

I’m learning how to set up rules in Openhab. In other words I’m reading the docs and learning from the posts in the community…but most inportantly I’m trying out a few things with the only purpose to understand how it all works.
I have come to a result that I just don’t understand.

This is the code:

ITEMS

Group gDoors "DeurSensoren_group"
DateTime ZWaveNode006FGK101DoorOpeningSensor_DoorSensor_LastUpdate "Back Door Last Update [%1$tm/%1$td %1tH:%1tM]" <clock>  (gDoors)

RULES

rule "Deur_open"
when
   Member of gDoors changed
then
  logInfo("rule.deuropen", "Member of gDoors:" + triggeringItem.label + " changed from " + previousState.toString + "to:" + triggeringItem.state.toString )
  postUpdate(triggeringItem.name+"_LastUpdate", now.toString)
end

And this is the logresult :

LOG

2019-04-22 10:36:10.258 [INFO ] [smarthome.model.script.rule.deuropen] - Member of gDoors:Door Sensor changed from CLOSEDto:OPEN

2019-04-22 10:36:10.311 [INFO ] [smarthome.model.script.rule.deuropen] - Member of gDoors:Back Door Last Update changed from 2019-04-22T10:35:46.162+0200to:2019-04-22T10:36:10.267+0200

So when I open a door, (the node006 thing )that is a member of gDoors, I get two lines logged
The first I understand because it is the change of the state of the door(node006 thing) that was opened.
The second I don’t get.
1° I didn’t ask for it so why log the change of the associated item _lastupdate? Does the script loops again over the first(and only logline)?
How come that the script doesn’t go to the “end” statement when it executed the postUpdate statement?

If somebody can explain what is happening so that a dummy like me understands I would be gratefull!!

Grts,
Mario

Every time a group member changes, the rule runs.
The two logInfos come from different passes, or runs, of the rule.
The logInfos refer to two different Items - one is labelled Door Sensor, the second is labelled Back Door Last Update
Are you seeing how this happens?
You probably don’t want your xxx_update Items to be members of the group that triggers this rule.

I’m surprised you don’t also see an error complaining that an Item xxx_update_update can’t be found for postUpdate on the second pass.

1 Like

Thx rossko57,

Took the associated item out of gDoors and the result was only one log as expected.
Seems logic now that you explained it.

It does, I was filtering the log so I didn’t see the error. If I would have seen the error I would probably have understood wat was happening.

Thx again;
Up to my next “overlooking the obvoius”

Grts,
Mario

Not at all obvious ; but do file under “check all the clues” :wink: