Simple rule given warning and ignoring

Can anyone tell me why this rule is given me a warning and ignoring:

log file:

2018-08-05 18:13:27.137 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'motionering.rules' has errors, therefore ignoring it: [9,1]: missing EOF at 'when'

.rule file

rule "Ventil motionering startet"

when
	Item aktivitetVentilMotion changed from 0 to 1       // motion begin
then
	aktivitetVentilMotionStamp.postUpdate(new DateTimeType())   // defaults to now
end

when
	Item amandaVentilMotion changed from 0 to 1       // motion begin
then
	amandaVentilMotionStamp.postUpdate(new DateTimeType())   // defaults to now
end

when
	Item bryggersVentilMotion changed from 0 to 1       // motion begin
then
	bryggersVentilMotionStamp.postUpdate(new DateTimeType())   //defaults to now
end

when
	Item casperVentilMotion changed from 0 to 1       // motion begin
then
	casperVentilMotionStamp.postUpdate(new DateTimeType())   //defaults to now
end

when
	Item koekkenVentilMotion changed from 0 to 1       // motion begin
then
	koekkenVentilMotionStamp.postUpdate(new DateTimeType())   //defaults to now
end

when
	Item kontorVentilMotion changed from 0 to 1       // motion begin
then
	kontorVentilMotionStamp.postUpdate(new DateTimeType())   //defaults to now
end

when
	Item lilleBadVentilMotion changed from 0 to 1       // motion begin
then
	lilleBadVentilMotionStamp.postUpdate(new DateTimeType())   //defaults to now
end

when
	Item marcVentilMotion changed from 0 to 1       // motion begin
then
	marcVentilMotionStamp.postUpdate(new DateTimeType())   //defaults to now
end

when
	Item soveBadVentilMotion changed from 0 to 1       // motion begin
then
	soveBadVentilMotionStamp.postUpdate(new DateTimeType())   //defaults to now
end

when
	Item spisestueVentilMotion changed from 0 to 1       // motion begin
then
	spisestueVentilMotionStamp.postUpdate(new DateTimeType())   //defaults to now
end

when
	Item stortBadVentilMotion changed from 0 to 1       // motion begin
then
	stortBadVentilMotionStamp.postUpdate(new DateTimeType())   //defaults to now
end

when
	Item stueBadVentilMotion changed from 0 to 1       // motion begin
then
	stueBadVentilMotionStamp.postUpdate(new DateTimeType())   //defaults to now
end

You has defined only one rule with pattern

rule "my rule"
when
    Item myItem changed
then
    do some thing
end

all your other “rule” are missing the rule an therefore openHAB finds an error

It is simular to this rule I´ve got, which is working just fine. So I don´t really understand why the above fails.

rule "Multisensor6 PIR Last Updated"
when
	Item ZWaveNode5ZW100MultiSensor6_MotionAlarm changed from OFF to ON       // motion begin
then
	ZWaveNode5ZW100MultiSensor6_MotionAlarm_stamp.postUpdate(new DateTimeType())   //defaults to now
    logInfo("PIRupdate.rules", "Multisensor 6 opdatering.")
       // ..... do other stuff
end

This rule is complete, but your rule set isn’t complete. i just copied from your rule

rule "Ventil motionering startet"

when
	Item aktivitetVentilMotion changed from 0 to 1       // motion begin
then
	aktivitetVentilMotionStamp.postUpdate(new DateTimeType())   // defaults to now
end

<<<----- Here is something missing ----->
rule "This is the next rule"
when
	Item amandaVentilMotion changed from 0 to 1       // motion begin
then
	amandaVentilMotionStamp.postUpdate(new DateTimeType())   // defaults to now
end

Compare this to your rule/ rules

So what you say is, that there has to be a rule “xxxx xxx xxx” after each end?

You should see it the other was round. each rule start with a rule and ends with end. You have, if i count right, 12 rules, but only one times the keyword rule.

A good practice on such errors (know knowing why there is an error) is to put most of the code into comments and adds parats by parts until the error comes up.

I hear you, and I´ll give it a try. But this is my rule file for setting a datetime stamp whenever a motion PIR is changed. It´s working just fine, and does not threw an warning. Please notice the exact same process:

rule "Multisensor6 PIR Last Updated"
when
	Item ZWaveNode5ZW100MultiSensor6_MotionAlarm changed from OFF to ON       // motion begin
then
	ZWaveNode5ZW100MultiSensor6_MotionAlarm_stamp.postUpdate(new DateTimeType())   //defaults to now
    logInfo("PIRupdate.rules", "Multisensor 6 opdatering.")
       // ..... do other stuff
end

//Soveværelse
rule "Soveværelse PIR Last Updated"
when
	Item sove_pir changed from OFF to ON       // motion begin
then
	sove_pir_stamp.postUpdate(new DateTimeType())   //defaults to now
end

//Stuen
rule "Stue PIR Last Updated"
when
	Item stue_pir changed from OFF to ON       // motion begin
then
	stue_pir_stamp.postUpdate(new DateTimeType())   //defaults to now
end

//Spisestuen
rule "Spisestue PIR Last Updated"
when
	Item spise_pir changed from OFF to ON       // motion begin
then
	spise_pir_stamp.postUpdate(new DateTimeType())   //defaults to now
end

//Aktivitetsrum
rule "Aktivitestrum PIR Last Updated"
when
	Item aktivitet_pir changed from OFF to ON       // motion begin
then
	aktivitet_pir_stamp.postUpdate(new DateTimeType())   //defaults to now
end

//Caspers
rule "Aktivitestrum PIR Last Updated"
when
	Item casper_pir changed from OFF to ON       // motion begin
then
	casper_pir_stamp.postUpdate(new DateTimeType())   //defaults to now
end

//Amandas
rule "Aktivitestrum PIR Last Updated"
when
	Item amanda_pir changed from OFF to ON       // motion begin
then
	amanda_pir_stamp.postUpdate(new DateTimeType())   //defaults to now
end

//Marcs
rule "Aktivitestrum PIR Last Updated"
when
	Item marc_pir changed from OFF to ON       // motion begin
then
	marc_pir_stamp.postUpdate(new DateTimeType())   //defaults to now
end

//Garage
rule "Garage PIR Last Updated"
when
	Item garage_pir changed from OFF to ON       // motion begin
then
	garage_pir_stamp.postUpdate(new DateTimeType())   //defaults to now
end

//Udvendig indgangsparti
rule "Udv indgang PIR Last Updated"
when
	Item pir_indgang changed from OFF to ON       // motion begin
then
	pir_indgang_stamp.postUpdate(new DateTimeType())   //defaults to now
end

rule "Vision PIR alarm"
when
	Item Node10_AlarmBurglar changed from OFF to ON       // motion begin
then
	Node10_AlarmBurglar_stamp.postUpdate(new DateTimeType())   //defaults to now

end

rule "Neo Coolcam PIR alarm"
when
	Item Node13_AlarmBurglar changed from OFF to ON       // motion begin
then
    logInfo("item", "ZwaveNode13 sets update.")	
	Node13_AlarmBurglar_stamp.postUpdate(new DateTimeType())   //defaults to now

end

rule "Vision Garageport sensor"
when
	Item GarageDoorTiltSensor_BinarySensor changed from CLOSED to OPEN       // motion begin
then
	GarageDoorTiltSensor_BinarySensor_stamp.postUpdate(new DateTimeType())   //defaults to now

end

I would suspect this gave an warning and ignoring as well. This is actually my reference rule for the above, which is not working.

Just tried. And you were right. It no longer throws an warning…

ARRGH… Damit, I see it now… The reference rules DO contain rule “” for each rule…
Damit I´m tired :frowning: Sorry for taking your time.

Hello @Kim_Andersen
I see that you have solved the problem you had.
Now, you end up with 12 rules.
These 12 rules can be put into ONE!!! Yes

Put all the items triggering the rules into a Group:

Group gVentilMotion

Rule:

rule "Ventil mitionering startet"
when
    Member of gVentilMotion changed from 0 to 1
then
    val String itemName = triggeringItem.name.toString
    postUpdate(itemName + "Stamp", now.toString)
end

That’s it…
From 72 lines of code to 7

2 Likes

:slight_smile: no problem. take a nap and start coding again

Thanks alot Vincent.
I knew there probably were some way to make this more simple. I just didn´t have the knowledge to do it. Now I do :slight_smile:
I will give it a try later. It´s not fun doing alot of unnessesary copy/paste :slight_smile:

trigger should be

Member of gVentilMotion changed from 0 to 1

:wink:

@vzorglub
And it works like a dream, even with Udo´s change, (which I had spotted btw :slight_smile: )