Away Switch rule for security would not turn on Sirens

Platform information:

  • Hardware: Raspberry Pi 3 Model B Rev 1.2
  • OS: OpenHAB
  • openHAB version: openHAB 2.5.5-1 (Release Build)
  • Motion detecor and Siren: NEO

Hi everyone,
I am trying to make a rule that when someone is going away from home then they can switch a Switch item in the Sitemap that turns a Rule on which then if motion is detected through Group of motion detectors it will turn on Group of sirens in the house

These are my Items

//State switch
Switch awaySwitch "Away" <alarm>

Group motion_zwave "motion sensors" <motion>
Group light_zwave "Fibaro lights" <light>
Group siren_zwave "Siren" <siren>

This is my rule

//When person is away from home
rule "Armed House"
        Item awaySwitch changed to ON
        if(motion_zwave.state == ON) {

However nothing happens when I move my hand in front of motion detector and the detector works because I am using it for turning on the lights as well as I can turn siren on manualy. There are no Errors in the logs and if I turn on the awaySwitch and the motion switch it aprears in the logs.

2020-06-29 18:55:47.856 [ome.event.ItemCommandEvent] - Item 'awaySwitch' received command ON

2020-06-29 18:55:47.869 [vent.ItemStateChangedEvent] - awaySwitch changed from OFF to ON

2020-06-29 18:55:54.864 [vent.ItemStateChangedEvent] - zwave_device_f57cb095_node15_alarm_motion changed from OFF to ON

2020-06-29 18:56:08.294 [ome.event.ItemCommandEvent] - Item 'awaySwitch' received command OFF

2020-06-29 18:56:08.306 [vent.ItemStateChangedEvent] - awaySwitch changed from ON to OFF

2020-06-29 18:56:13.734 [ome.event.ItemCommandEvent] - Item 'awaySwitch' received command ON

2020-06-29 18:56:13.764 [vent.ItemStateChangedEvent] - awaySwitch changed from OFF to ON

2020-06-29 18:56:24.184 [vent.ItemStateChangedEvent] - zwave_device_f57cb095_node16_alarm_motion changed from OFF to ON

2020-06-29 18:56:24.191 [ome.event.ItemCommandEvent] - Item 'FibaroDimmer1_DimmerSwitch1' received command ON

2020-06-29 18:56:24.253 [nt.ItemStatePredictedEvent] - FibaroDimmer1_DimmerSwitch1 predicted to become ON

2020-06-29 18:56:24.291 [vent.ItemStateChangedEvent] - FibaroDimmer1_DimmerSwitch1 changed from 0 to 100

2020-06-29 18:56:25.459 [vent.ItemStateChangedEvent] - zwave_device_f57cb095_node11_sensor_power changed from 0 to 1

2020-06-29 18:56:25.876 [vent.ItemStateChangedEvent] - zwave_device_f57cb095_node11_switch_dimmer1 changed from 0 to 2

2020-06-29 18:56:25.880 [vent.ItemStateChangedEvent] - FibaroDimmer1_DimmerSwitch1 changed from 100 to 2

2020-06-29 18:56:29.468 [vent.ItemStateChangedEvent] - zwave_device_f57cb095_node11_sensor_power changed from 1 to 1.5

2020-06-29 18:56:52.011 [vent.ItemStateChangedEvent] - zwave_device_f57cb095_node15_alarm_motion changed from ON to OFF

2020-06-29 18:56:55.222 [vent.ItemStateChangedEvent] - zwave_device_f57cb095_node16_alarm_motion changed from ON to OFF

2020-06-29 18:57:03.501 [ome.event.ItemCommandEvent] - Item 'FibaroDimmer1_DimmerSwitch1' received command OFF

2020-06-29 18:57:03.564 [nt.ItemStatePredictedEvent] - FibaroDimmer1_DimmerSwitch1 predicted to become OFF

2020-06-29 18:57:03.582 [vent.ItemStateChangedEvent] - FibaroDimmer1_DimmerSwitch1 changed from 2 to 0

2020-06-29 18:57:04.532 [vent.ItemStateChangedEvent] - zwave_device_f57cb095_node11_sensor_power changed from 1.5 to 0.4

2020-06-29 18:57:05.162 [vent.ItemStateChangedEvent] - zwave_device_f57cb095_node11_switch_dimmer1 changed from 2 to 0

2020-06-29 18:57:14.557 [vent.ItemStateChangedEvent] - zwave_device_f57cb095_node11_sensor_power changed from 0.4 to 0

2020-06-29 18:58:24.205 [ome.event.ItemCommandEvent] - Item 'FibaroDimmer1_DimmerSwitch1' received command OFF

2020-06-29 18:58:24.319 [nt.ItemStatePredictedEvent] - FibaroDimmer1_DimmerSwitch1 predicted to become OFF

I am quite new to rules and openhab so I appologize if the rule is horrible.

What your rule does, is run when your awaySwitch changes to ON. It does the check you asked for, and then finishes. All within a few milliseconds. It will not run again until the next time awaySwitch changes to ON.

I suspect you are looking for something more like a rule that runs whenever motion is detected, and then looks to see if awaySwitch is ON before deciding what to do about it.

So I tried your suggestion and made the rule or at least what I though would work but it did not work so I am wondering if thats what you ment

rule "Armed House 2"
        Item motion_zwave received command ON
        if(awaySwitch.state == ON) {

Try changed to rather than received command

yeah I did it did not work either

As @hafniumzinc pointed out, you are not likely to get a command from a sensor.

But you also need to think about the Item involved. I don’t see any activity in your events.log to do with any Item called motion_zwave
You’ve defined a Group by that name, but no type or function for the Group yet, so its state will never change.

Guessing it is a Group of what, switches? That go ON for motion? You could use a Member of trigger for your rule

   Member of motion_zwave changed to ON

What do you mean by type or function of a Group? Could you explain what is it or point me to where I can find the information on it and maybe an example of how it would look?


1 Like

Could you tell me if that looks better

Group:Switch:OR(ON,OFF) motion_zwave "motion sensors" <motion>
Group:Switch:OR(ON,OFF) light_zwave "Fibaro lights" <light>
Group:Switch:OR(ON,OFF) siren_zwave "Siren" <siren>


rule "Armed House 2"
  Member of motion_zwave changed to ON
  if (awaySwitch.state == ON) {

Question: Did you add your motion devices to the ‘motion_zwave’ group in your items file? Please post all content of that file here please.

I don’t know what you want, so no idea how you should set it.

If you don’t set a Group type and function, the Groups state would never change, so your first rule could never work.

You don’t need to set a Group type and function for a rule ‘Member of’ trigger to work. It doesn’t care either way, because it is interested in member Items.

The way you have it now -
If any members are state ON, the Group’s state will be ON. Otherwise it willbe OFF.
I don’t know if you want that, perhaps it is useful for display.
Note that if one member is ON, so the Group will be ON. If a second member comes ON, nothing happens to the Group because it is already ON.

1 Like