i am writing some openhab rules using groups but i struggle with one rule.
I have a velbus setup with motion detectors, i am trying to use groups to handle my silent alarm system. My motion detector states are “Pressed” and “Released”.
I see in my logs that i receive the update of the detectors. But rule below doesn’t get triggered.
Rule:
rule "Motion Detected"
when
Member of gMotion changed
then
logInfo("Motion detected", "The item " + triggeringItem.name + " changed state to " + triggeringItem.state)
items
Group gMotion
Switch GF_Entryway_Motion "Motion Sensor" <motion> (GF_Entryway, gMotion)
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.
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
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
6
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).
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?
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.
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
11
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.
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
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
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
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
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.
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
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?
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