Group rules

But the rule triggers on change. Could you show us the events.log of your Item changing?

Check in openhab.log that your rules file loads successfully.

Check with REST API that your Group includes that Item as member.

Hi,
The suggestions that @rossko57 made look valid.
The log entry that you’ve made probably won’t work since you’ll need to convert the state to a string.

You seem to be miising an end to your rule

The rule only triggers if one of the detectors changed his stated. So even if there is an update, the rule won’t trigger. Try to change Member of gMotion changed into Member of gMotion received update.

3 Likes

Hi

I’m sure that the trigger channels of Velbus Things can not be linked to items. (It’s more obvious when using PaperUI)

You can monitor these channels in rules (and NodeRed).

#Rossko57 helped me with a similar issue here

Hello, had some time to try all of your solutions but no succes.

rule "Motion Detected"
when
    Member of gMotion received update
then
	logInfo("Motion detected", "The item " + triggeringItem.name + " changed state to " + triggeringItem.state.toString)

end
2019-09-15 13:46:19.117 [vent.ItemStateChangedEvent] - Consumption_Boiler_Now changed from 0.02746623941405356 to 0
2019-09-15 13:46:23.337 [vent.ItemStateChangedEvent] - GF_Driveway_Temperature changed from 40.5625 to 40.1875
2019-09-15 13:47:49.921 [vent.ChannelTriggeredEvent] - velbus:vmbpirm:ff422af2:19:input#CH3 triggered PRESSED
2019-09-15 13:47:52.831 [vent.ChannelTriggeredEvent] - velbus:vmbpirm:ff422af2:11:input#CH3 triggered PRESSED
2019-09-15 13:47:52.860 [vent.ItemStateChangedEvent] - GF_Toilet_Light changed from OFF to ON
2019-09-15 13:47:52.894 [vent.ItemStateChangedEvent] - Ventilatie_Speed2 changed from OFF to ON
2019-09-15 13:47:52.901 [vent.ItemStateChangedEvent] - Ventilatie_Level changed from 1 to 2
2019-09-15 13:47:52.907 [ome.event.ItemCommandEvent] - Item 'Ventilatie_Speed2' received command ON
2019-09-15 13:47:52.915 [ome.event.ItemCommandEvent] - Item 'Ventilatie_Speed3' received command OFF
2019-09-15 13:47:52.919 [nt.ItemStatePredictedEvent] - Ventilatie_Speed2 predicted to become ON
2019-09-15 13:47:52.925 [nt.ItemStatePredictedEvent] - Ventilatie_Speed3 predicted to become OFF
2019-09-15 13:47:53.960 [vent.ChannelTriggeredEvent] - velbus:vmbpirm:ff422af2:20:input#CH3 triggered PRESSED
2019-09-15 13:47:58.678 [vent.ChannelTriggeredEvent] - velbus:vmbpirm:ff422af2:18:input#CH7 triggered RELEASED
2019-09-15 13:47:58.843 [vent.ChannelTriggeredEvent] - velbus:vmbpirm:ff422af2:18:input#CH3 triggered PRESSED

The vmbirm are the ones who should be in the group.
Mdar from your post i can conclude that the binding of velbus don’t support groups yet? For the sensors? And input module?

Mathieu

No binding knows anything about Groups. Groups are to do with Items.

You can’t link a trigger type channel to an Item, so you cannot use trigger type channels with Groups.

“Ordinary” channels can be linked to Items. Items of course, can be added to Groups.

Groups cannot have members like
velbus:vmbpirm:ff422af2:20:input#CH3
Groups can have members like
GF_Toilet_Light

What’s in your Group?

Well that is the strange thing, the items are not showing up in the logs.
Definition of a motion sensor:

Switch          GF_Kitchen_Motion              "Motion Sensor"       <motion>           (GF_Kitchen, gMotion)                               		{channel="velbus:vmbpirm:ff422af2:20:input#CH3"}

Group:

Group gMotion

Maybe the problem is with the state names? A switch is “ON” and “OFF”, my motion is “PRESSED” and “RELAESED”.

What i could do is make a rule for each motion sensor that it updates an item.
Afterwards the group will be receiving an update. Like in MDAR his post.

You’ve missed the point made in this thread, your PRESSED is an event occurring in a trigger type channel. You cannot link trigger type channels to Items, it does not work, as you have found out. Items expect state updates not trigger events.

You will need to identify a state channel from the binding that works for Items, or trigger a rule from trigger events but not use Groups.

Have you taken the time to read every comment on the thread I linked to?

It has all the answers you’re looking for.

In short, you’re missing a vital bit of information regarding Trigger Channels Vs State channels.
Which is covered in the article I’ve linked to.

There is even an example rule in there that you can adapt.

Hi all,

I have quite a similar problem:
I’ve created a Group for Window Sensors:

Group:Contact:OR(OPEN, CLOSED) gEGWindowSensors

The rule is:

rule "Check Alarm occur"
when
      Member of gEGWindowSensors changed
then
            logInfo("Alarm_System", "Entered rule: Check Alarm occur")
                val WindowSensors = triggeringItem
                var alert = false
            if (WindowSensors.state == OPEN) {
            
            logInfo("Alarm_System", "gEGWindowSensors item changed " + WindowSensors.name + " is OPEN! ")

                if (Alarmanlage_Status.state == ON)
                {   
                    logInfo("Alarm_System", "Alarm-System on and gEGWindowSensors item changed")
                        if (AlarmProfile.state == "ABSENT"){
                            alert = true
                            logInfo("Alarm_System", "Alarm occur! System active and profile: ABSENT")
                        }
                        if (AlarmProfile.state == "HOME"){
                            alert = true
                            logInfo("Alarm_System", "Alarm occur! System active and profile: HOME")
                        }
                        if (AlarmProfile.state == "VACATION"){
                            alert = true
                            logInfo("Alarm_System", "Alarm occur! System active and profile: VACATION")
                        }
                    
                }
                if (alert){
            
                // do the alarm stuff here!

                    // send alarm signal to siren
                    sendCommand(FunkSirene_Channel1_Outside_State, ON)
                    logInfo("Alarm_System","ALARM: Siren was triggered!")
                    Thread::sleep(1000)
                    // send Notification to app
                    
                    sendBroadcastNotification("Einbruch-ALARM! Am: "+ FormattedDate.state.format("%1$td.%1$tm.%1$ty %1$tH:%1$tM") +" Uhr")
                    logInfo("Alarm_System","ALARM: Broadcast message was send!")
                    Thread::sleep(1000)    
                }
            }
            else {
                // empty AlarmStatus Text
                sendCommand(AlarmStatusText, "")
            }
end

But the rule won’t be fired.
In the event logs the Group contact is changed:
gEGWindowSensors changed from OPEN to CLOSED through Kitchen_WindowSensor1_State

any ideas why the rule is not fired?!

Ok let’s tidy up a bit:

rule "Check Alarm occur"
when
    Member of gEGWindowSensors changed
then
    logInfo("Alarm_System", "Entered rule: Check Alarm occur")
    val WindowSensors = triggeringItem
    var alert = false
    if (WindowSensors.state == OPEN) {
        logInfo("Alarm_System", "gEGWindowSensors item changed " + WindowSensors.name + " is OPEN! ")
        if (Alarmanlage_Status.state == ON) {   
            logInfo("Alarm_System", "Alarm-System on and gEGWindowSensors item changed")
            if (AlarmProfile.state == "ABSENT") {
                alert = true
                logInfo("Alarm_System", "Alarm occur! System active and profile: ABSENT")
            }
            if (AlarmProfile.state == "HOME") {
                alert = true
                logInfo("Alarm_System", "Alarm occur! System active and profile: HOME")
            }
            if (AlarmProfile.state == "VACATION"){
                alert = true
                logInfo("Alarm_System", "Alarm occur! System active and profile: VACATION")
            }
        }
        if (alert) {
            // do the alarm stuff here!
            // send alarm signal to siren
            FunkSirene_Channel1_Outside_State.sendCommand(ON)
            logInfo("Alarm_System","ALARM: Siren was triggered!")
            Thread::sleep(1000)
            // send Notification to app
            sendBroadcastNotification("Einbruch-ALARM! Am: "+ FormattedDate.state.format("%1$td.%1$tm.%1$ty %1$tH:%1$tM") +" Uhr")
            logInfo("Alarm_System","ALARM: Broadcast message was send!")
            Thread::sleep(1000)    
        }
    } else {
        // empty AlarmStatus Text
        AlarmStatusText.sendCommand("")
    }
end

Note that I changed the sendCommand action to the item methods

Next, comment out the rule except the first logInfo

rule "Check Alarm occur"
when
    Member of gEGWindowSensors changed
then
    logInfo("Alarm_System", "Entered rule: Check Alarm occur")
/*
    val WindowSensors = triggeringItem
    var alert = false
    if (WindowSensors.state == OPEN) {
        logInfo("Alarm_System", "gEGWindowSensors item changed " + WindowSensors.name + " is OPEN! ")
        if (Alarmanlage_Status.state == ON) {   
            logInfo("Alarm_System", "Alarm-System on and gEGWindowSensors item changed")
            if (AlarmProfile.state == "ABSENT") {
                alert = true
                logInfo("Alarm_System", "Alarm occur! System active and profile: ABSENT")
            }
            if (AlarmProfile.state == "HOME") {
                alert = true
                logInfo("Alarm_System", "Alarm occur! System active and profile: HOME")
            }
            if (AlarmProfile.state == "VACATION"){
                alert = true
                logInfo("Alarm_System", "Alarm occur! System active and profile: VACATION")
            }
        }
        if (alert) {
            // do the alarm stuff here!
            // send alarm signal to siren
            FunkSirene_Channel1_Outside_State.sendCommand(ON)
            logInfo("Alarm_System","ALARM: Siren was triggered!")
            Thread::sleep(1000)
            // send Notification to app
            sendBroadcastNotification("Einbruch-ALARM! Am: "+ FormattedDate.state.format("%1$td.%1$tm.%1$ty %1$tH:%1$tM") +" Uhr")
            logInfo("Alarm_System","ALARM: Broadcast message was send!")
            Thread::sleep(1000)    
        }
    } else {
        // empty AlarmStatus Text
        AlarmStatusText.sendCommand("")
    }
*/
end

Does is trigger?

Thanks for the help.
What do you mean with " Note that I changed the sendCommand action to the item methods" ?

I’ve changed the rule but with no effect :frowning:
In event.log I could see only:

2019-09-22 08:34:11.639 [GroupItemStateChangedEvent] - gEGWindowSensors changed from CLOSED to OPEN through GuestToi_WindowSensor1_State
2019-09-22 08:34:11.643 [vent.ItemStateChangedEvent] - GuestToi_WindowSensor1_State changed from CLOSED to OPEN

I have no clue why the rule is not triggered?!

You’ve been editing your rules and Items, no doubt.
I got frustrated just the other day with a test member-of group rule trigger that simply wouldn’t, but surely must!
After a reboot, all fine. (OH2.4)

I think the triggering listener can get messed up during edits.

Nope. A reboot changes nothing :frowning:
All other rules work fine.
But the only rule using a Group item will not work…very frustrating :frowning:

Do I have to use:
Item gEGWindowSensors changed
istead of:
Member of gEGWindowSensors changed

Any other ideas?

That is up to you, these are two completely different conditions.
A member of some Group can change without affecting the state of the Group.

Does your rule file actually load? (find message in openhab.log)

Do have only one rule in your whole system called "Check Alarm occur" ?

  • Yes not error or message in openhab.log All rules are load with no warnings.
  • Yes all my rules have a unique name

I’ve solved the problem by using all items in that rule connected with an or:
Item Kitchen_WindowSensor1_State changed or
Item WHZ_WindowSensor3_terrace_State changed or
Item WHZ_WindowSensor2_middel_State changed or
Item WHZ_WindowSensor1_front_State changed or
Item GuestToi_WindowSensor1_State changed

not that what I want but the result is does that what it should :wink:

Maybe or I’m sure something is wrong regading the group setting.

What I try to achieve is that if some of the window sensors are opend the group item should set to open, if all sensors are closed the group item should set to closed.

The definition of my group:
Group:Contact:OR(OPEN, CLOSED) gEGWindowSensors

From my understanding this should behave like this: If one sensor is opened set the group to open, right?

Maybe here is a configuration issue?!

Yes, that is correct.

That has absolutely nothing to do with rules; the Group works out it’s state using the OR(OPEN, CLOSED) part completely independently of any rules.
You’ve already shown us that part working from your events.log

Okay thank you.
I guess we would not solve the first issue. But I’m fine with my “workaround” :wink:

Member of works for others.

I personally have several rules triggered from Member of , the Groups have Contact type members, some of the Groups are themselves of Contact type and have an OR aggregate function, some are just default no-type.