[SOLVED] "Member of" rule not working?!? HINT: It was my fault after all :(

Hi,
I’m struggling… :confused:
I have setup two rules that seem to be the same to me. One is working, the other is not.

I have two contact groups for windows (G_windows) and doors (G_Doors) (Yes, one uppercase, one lowercase…):

The groups work correctly.
If I open a door or a window, the icon immediately changes from closed to open, if at least one door/window is open.
So far so good.

I added two settings items and two rules to send notifications, when doors/windows are opened as follows.

For the windows:

val mailActions = getActions("mail","mail:smtp:XXX")
rule "Window Monitor"
when Member of G_windows changed from CLOSED to OPEN
then
    logInfo("Windows", "Fenster " + triggeringItem.label + " wurde geöffnet. (Notifications: " + Settings_WindowNotifications.state + ")")
    if (Settings_WindowNotifications.state == ON) {
        var report = ""
        G_windows.allMembers.filter([state == OPEN]).forEach([ContactItem item | report = report + "\n" + item.label     ])
        val message = "Diese Fenster sind geöffnet:\n" + report
        mailActions.sendMail("me@...", "Fenster " + triggeringItem.label + " wurde geöffnet", message)
        pushsafer("...", message, "Fenster " + triggeringItem.label + " wurde geöffnet", "", "81", "", "")
    }
end

For the doors:

val mailActions = getActions("mail","mail:smtp:XXX")

rule "Door Monitor"
when Member of G_Doors changed from CLOSED to OPEN
then
    logInfo("Doors", "Tür " + triggeringItem.label + " wurde geöffnet. (Notifcations: " + Settings_DoorNotifications.state + ")")
    if (Settings_DoorNotifications.state == ON){
        var report = ""
        G_Doors.allMembers.filter([state == OPEN]).forEach([ContactItem item | report = report + "\n" + item.label ])
        val message = "Diese Türen sind geöffnet:\n" + report
        mailActions.sendMail("me@,,,", "Tür " + triggeringItem.label + " wurde geöffnet", message)
        pushsafer("...", message, "Tür " + triggeringItem.label + " wurde geöffnet", "", "81", "", "")
    }
end

Both settings that configure, whether notifications should be sent or not are set to true
When I open a window, I get both the pushsafer notification, as well as the mail.
As well, the initial logInfo is added.
When I open a door nothing happens at all.
Not even the initial logInfo message.

To me, the rules look exactly the same.
The G_doors group itself is working, as the icon changes as soon as the first door is opened.

I’m out of ideas :frowning:
Can someone see, what I have overlooked???

Thanks a lot for your help!

I don’t know if this is the problem, but in your door rule there’s a typo in the loginfo:

(Notifcations: " + Settings_DoorNotifications.state + “)”)

Usually when I’m debugging, I’ll comment lines out and then add them back in piece by piece to isolate the issues.

1 Like

Thanks for noticing! Unfortunately, it was only in the string that’s being logged, so it doesn’t solve my issue.

I commented out everything in the rule and tried with the logging only.
I changed the group from G_Doors to G_windows and backwards in the same rule file.
The other rule for the windows is untouched and working.
The window group triggers the rule, the door group does not.

I don’t see a difference between these groups :frowning:

// NOT working
rule "Door Monitor"
when Member of G_Doors changed from CLOSED to OPEN
then
    logInfo("Doors", "Tür " + triggeringItem.label + " wurde geöffnet. (Notifications: " + Settings_DoorNotifications.state + ")")
end

// working
rule "Door Monitor"
when Member of G_windows changed from CLOSED to OPEN
then
    logInfo("Doors", "Tür " + triggeringItem.label + " wurde geöffnet. (Notifications: " + Settings_DoorNotifications.state + ")")
end

In the rules DSL, the names of the rules must be unique. Are there any errors in the openhab.log file when saving or triggering the other rules? Or saving the file with the group Items? (the group Items are managed)

No errors.
These are my last log lines:

2020-11-18 08:03:25.828 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'doors.rules'
2020-11-18 08:06:41.414 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'doors.rules'
2020-11-18 08:06:50.997 [INFO ] [lipse.smarthome.model.script.Windows] - Fenster Büro, rechts wurde geöffnet. (Notifications: ON)
2020-11-18 08:06:51.000 [INFO ] [eclipse.smarthome.model.script.Doors] - Tür Büro, rechts wurde geöffnet. (Notifications: ON)
2020-11-18 08:07:12.996 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'doors.rules'

The logline “Tür Büro, rechts wurde geöffnet.” was logged, when I tested the rule with the group “G_windows” to see, if the rule itself triggers.

What is logged in event.log for the state of the G_Doors group when one of its members changes state?

Nothing specific in the openhab.log.
I just verified that the group is working by looking into the app on the phone, when I opened a door.
The icon immediately changes according to the “One OPEN -> OPEN else CLOSED” setting.

How about the event.log file? What is logged with…

rule "Door Monitor test"
when 
    System started
then
    logInfo("Doors", "group state: {}, item: {}", G_Doors.state, G_Doors)
end

I thought I was stupid, but this doesn’t log anything at all…
I added logInfo(“startup”, “Rule System starting started”) to be sure that the rule triggers.

All I see in the logs is:

2020-11-18 09:28:47.228 [INFO ] [lipse.smarthome.model.script.startup] - Rule System starting started

As it the G_Doors group is not recognized at all…

Oh wow…
G_doors…
I’m profoundly sorry for the confusion my stupidity caused.
It was probably way too late yesterday and I just double checked now to be sure.
Of course it’s a small d in G_doors…

Thanks for your help and suggestions!!

1 Like