Great results with this rule but I’d like to expand on it. Right now, the motion sensor will trip under motion and turn the lights on with a Dim setting of 5%.
This works great!
However, what I want to do is this:
If the lights have been set manually or via some other method (kinda irrelevant) to anything about 15% Dim, then dont turn them off automatically.
Im struggling with the logic, as usual
May someone make a suggestion?
Thankyuo!
var Timer Eye1_Timer = null
val Integer Eye1_TimeOut = 2
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 (FibaroEye1Lux.state < 20) {
if (Eye1_Timer !== null) {
LivingRoomDim1.sendCommand("5")
logInfo("FibaroEye1Motion","Eye1 Timer rescheduled for " + Eye1_TimeOut + " minutes")
Eye1_Timer.reschedule(now.plusMinutes(Eye1_TimeOut))
} else {
logInfo("FibaroEye1Motion", "Eye1 Motion Detected! Turning ON Living Room Lights")
LivingRoomDim1.sendCommand("5")
logInfo("FibaroEye1Motion","Eye1 Timer created with " + Eye1_TimeOut + " minutes")
Eye1_Timer = createTimer(now.plusMinutes(Eye1_TimeOut))
[ |
if (FibaroEye1Motion.state == ON) {
logInfo("FibaroEye1Motion","Eye1 Timer triggered, but rescheduled again for " + Eye1_TimeOut + " minutes")
Eye1_Timer.reschedule(now.plusMinutes(Eye1_TimeOut))
} else {
logInfo("FibaroEye1Motion", "Eye1 No Motion Detected! Turning OFF Living Room Lights")
LivingRoomSw1.sendCommand("OFF")
Eye1_Timer = null
}
]
}
}
end
Sorry i should mention I want to leave the current rule as is! But append it, to allow this new functionality… ie when its manually turned on with brightness above 15, dont run the previous rule.
then
var int Dim = 0
try {Dim = Integer::parseInt(LivingRoomDim1.state.toString)} catch (Exception e) {}
if (FibaroEye1Lux.state < 20 && Dim < 15) {
...
17:56:11.258 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'LivingRoomDim1' received command 46
17:56:11.261 [INFO ] [smarthome.event.ItemStateChangedEvent] - LivingRoomDim1 changed from 5 to 46
17:56:35.932 [INFO ] [smarthome.event.ItemStateChangedEvent] - FibaroEye1Motion changed from ON to OFF
17:57:37.708 [INFO ] [smarthome.event.ItemStateChangedEvent] - LivingRoomSw1 changed from OFF to ON
17:57:37.802 [INFO ] [smarthome.event.ItemStateChangedEvent] - LivingRoomNum1 changed from 0 to 43.3
17:57:54.939 [INFO ] [arthome.model.script.FibaroEye1Motion] - Eye1 No Motion Detected! Turning OFF Living Room Lights
17:57:54.942 [INFO ] [smarthome.event.ItemCommandEvent ] - Item 'LivingRoomSw1' received command OFF
17:57:54.945 [INFO ] [smarthome.event.ItemStateChangedEvent] - LivingRoomSw1 changed from ON to OFF
The rule was accepted fine in the console, no syntax errors.
var Timer Eye1_Timer = null
val Integer Eye1_TimeOut = 2
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
var int Dim = 0
try {Dim = Integer::parseInt(LivingRoomDim1.state.toString)} catch (Exception e) {}
if (FibaroEye1Lux.state < 20 && Dim < 15) {
if (Eye1_Timer !== null) {
LivingRoomDim1.sendCommand("5")
logInfo("FibaroEye1Motion","Eye1 Timer rescheduled for " + Eye1_TimeOut + " minutes")
Eye1_Timer.reschedule(now.plusMinutes(Eye1_TimeOut))
} else {
logInfo("FibaroEye1Motion", "Eye1 Motion Detected! Turning ON Living Room Lights")
LivingRoomDim1.sendCommand("5")
logInfo("FibaroEye1Motion","Eye1 Timer created with " + Eye1_TimeOut + " minutes")
Eye1_Timer = createTimer(now.plusMinutes(Eye1_TimeOut))
[ |
if (FibaroEye1Motion.state == ON) {
logInfo("FibaroEye1Motion","Eye1 Timer triggered, but rescheduled again for " + Eye1_TimeOut + " minutes")
Eye1_Timer.reschedule(now.plusMinutes(Eye1_TimeOut))
} else {
logInfo("FibaroEye1Motion", "Eye1 No Motion Detected! Turning OFF Living Room Lights")
LivingRoomSw1.sendCommand("OFF")
Eye1_Timer = null
}
]
}
}
end
Thanks Harry that seems to be working OK then. Ill test it a bit more.
Do you know why my switch doesnt turn on when the dimmer is more than 1%? Ie I used to be able with the FIbaro Zwave dimmer just drag the dimmer sliding and anything over 1% would turn the switch on?
It doesnt seem to do that.
I have the dimmer and switch linked to the Dimmer channel (switch_dimmer) in PaperUI