[SOLVED] Light override rule for Motion detection

Hi All,
I have a number of lights controller under motion that work really well.

I am having a party this weekend I’m thinking instead of motion turning lights on and off I think I’d like to have all motion switched off and just manual control of the lights.

Can anyone confirm if this is the right way to do this?

I’ve defined a group called

'gMotionSensors'

and placed all my Motion Sensoring channels into this from the various ZWave Motion sensors. I’ve defined a group called gAllDimmers and placed all my dimmers into the group so I can send a command of 5% to them all.

Here is my items:

/*Group Definitions for Switches*/
Group:Switch:SUM gAllLights            "All Lights"           [ "Lighting" ]
Group:Dimmer:SUM gAllDimmers        "All Dimmers"      [ "Lighting" }

Proxy Item:

Switch Motion_PartyMode                            "Proxy to Disable/Enable Motion Sensing for All Motion Sensors"

Rule:


rule "Disable All Motion Sensoring for Party"
when 
	Item Motion_PartyMode received command ON
then
        gMotionSensors.sendCommand(OFF)   // Disable all motion sensors from turning ON
        gAllDimmers.sendCommand(5)        // Turn All Lights on with Dimming set to 5%
        logInfo("All Motion Sensors", "All Motion Sensors off Due to Party Mode"
end 


rule "ReEnable All Motion Sensoring"
when
        Item Motion_PartyMode received command OFF
then
        gMotionSensors.sendCommand(ON)    // Disable all motion sensors from turning ON
        gAllDimmers.sendCommand(0)        // Turn All Lights on with Dimming set to 0%
           logInfo("All Motion Sensors", "All Motion Sensors off Due to Party Mode")
        Echo_Living_Room_TTS.sendCommand('Party Mode Disabled. All Motion Sensors ON. All Lights turned off')
end

typo at the end of the line (use ] instead of })

This won’t work…

In your “disable” rule:
You are sending an OFF command to the gMotionSensors Group. This means that all members of the Group will receive an OFF command.
This will not disable the Motion Sensors. It will just change their state to OFF at that moment. The next time they detect motion, they will send a status update (ON) to OH2 and your motion detection rule will fire.

You can’t really disable a Motion Sensor like this.

What you can do is go into your motion detection rule and add a check for the state of the Motion_PartyMode Item. If this is ON, do not execute the motion detection rule logic that turn on/off the lights.

For example:

rule "FE01_ON" // FibEye01 motion detection turns ON Staircase LEDs when dark and Party Mode is OFF
when
	Item FibEye01_Movement changed from OFF to ON
then
	if (FibEye01_Lux.state < 80 && Motion_PartyMode.state==OFF) {
...

Your gAllDimmers.sendCommand(5) will work fine as you have it in your Party rule.
Your rule title should be something like: rule "Enable Party Mode !!! Hurrah !

Have fun and drink responsibly :slight_smile:

1 Like

hahah Dim! Thanks mate :slight_smile:

OK I will make the suggested changes! the typo, I found earlier (forgot to edit the post!)

1 Like

Hi Dim,

Like so?



rule "FibaroEye1 motion detection turns ON Living Room Lights when Lux is less than 20, with a 2 Minute Inactivity Timer"
when
      Item FibaroEye1Motion changed to ON
then
      if(FibaroEye1Motion_Armed.state == ON && Motion_PartyMode.state !== ON){
        var int Dim = 0
           try {Dim = Integer::parseInt(LivingRoomDim1.state.toString)} catch (Exception e) {}
               if (FibaroEye1Lux.state < 20 && Dim < 31) {
                if (Eye1_Timer !== null) {
                        LivingRoomDim1.sendCommand("5")
                        logInfo("FibaroEye1Motion","Living Room Motion Timer rescheduled for " + Eye1_TimeOut + " minutes")
                        Eye1_Timer.reschedule(now.plusMinutes(Eye1_TimeOut))
                } else {
                        logInfo("FibaroEye1Motion", "Living Room Motion Detected! Turning ON Living Room Lights")
                        LivingRoomDim1.sendCommand("5")
                        logInfo("FibaroEye1Motion","Living Room Timer created with " + Eye1_TimeOut + " minutes")
                        Eye1_Timer = createTimer(now.plusMinutes(Eye1_TimeOut))
                        [ |
                                if (FibaroEye1Motion.state ==  ON) {
                                        logInfo("FibaroEye1Motion","Living Room Motion triggered, but rescheduled again for " + Eye1_TimeOut + " minutes")
                                        Eye1_Timer.reschedule(now.plusMinutes(Eye1_TimeOut))
                                } else {
                                        logInfo("FibaroEye1Motion", "Living Room, No Motion Detected! Turning OFF Living Room Lights")
                                        LivingRoomSw1.sendCommand("OFF")
                                        Eye1_Timer = null
                                }
                        ]
                }
        }
}
end

With:


rule "Disable All Motion Sensoring for Party"
when
        Item Motion_PartyMode received command ON
then
        gAllDimmers.sendCommand(5)        // Turn All Lights on with Dimming set to 5%
           logInfo("All Motion Sensors", "All Motion Sensors off Due to Party Mode")
        Echo_Living_Room_TTS.sendCommand('Party Mode Activated. All Motion Sensors Off. Lights set to five percent')
end

rule "ReEnable All Motion Sensoring"
when
        Item Motion_PartyMode received command OFF
then
        gAllDimmers.sendCommand(0)        // Turn All Lights on with Dimming set to 0%
           logInfo("All Motion Sensors", "All Motion Sensors off Due to Party Mode")
        Echo_Living_Room_TTS.sendCommand('Party Mode Disabled. All Motion Sensors ON. All Lights turned off')
end




!=ON not !==ON

if (FibaroEye1Motion_Armed.state == ON && Motion_PartyMode.state != ON) {
2 Likes

and since you are not disabling anything with this rule: go positive and say “Enable Party mode!” :slight_smile:

You can use this Party Switch for other use cases also later on if you would like.

Indeed!

Rules are very cool!!! and very powerful. Thanks for your help Dim & Vincent, I’ve just tested it and it’s working nicely.

1 Like

by the way: what is the concept behind this “Armed” ?

Keeps the dimmer off during a Movie, so if you’re moving around on the sofa the lights don’t go on and off :slight_smile:

1 Like

Your Disable All Motion Sensoring for Party and ReEnable All Motion Sensoring rules log the same message. This will be confusing when you check your log files :slight_smile:
I would simply replace both log messages with the messages that you send to the Echo_Living_Room_TTS item because it gives more insight in what all happens due to the state change.

2 Likes

Please mark the thread as solved. Thanks

1 Like