Rollershutter up --> lights off

Hi,

I would like to automatically switch off lights in a room as soon as the roller shutters have been opened.
I am wondering about the easiest solution to linking roller shutter and lights together.

This is my rule up to now:

rule "Test if roller shutter went up then switch off lights in the room"
when
Member of gShade changed
then
Thread::sleep(90000)
val delta_wert = triggeringItem.deltaSince(now.minusSeconds(120))
// Rolladen: 0: oben; 100: unten
// <0 wenn vorher 100 war und jetzt 0 (also oben) ist
if (delta_wert < -50) {
    logInfo("rolladen.rules", "Delta: "+ delta_wert + "; jetzt Lampe dazu suchen...")

}
end

Thanks,

Daniel

What don’t you like about it?

I don’t like the sleep, it’s really bad practice, but easily replaced with a timer later - once you’ve got the rest of the rule to your satisfaction.

I don’t understand the use of deltaSince. Is the requirement not “It’s changed, now it’s open, so let’s turn lights off if they’re on” ?

You are right, this does not make sense. I will just check if they are now open.

However, the bigger challenge for me is to find the right light to switch. The easiest would be to have an array of roller shutter --> light connections. Would that be possible?

Daniel

Hi Daniel,
have a look at this Design Pattern:


With associated names it should be possible to adress the light associated to the rollershutter.
Regards,
Oliver

I am mapping my motion sensors to my lights using map transform: https://www.openhab.org/addons/transformations/map/

In the rule: val lightName = transform(“MAP”, “motion_to_lights.map”, triggeringItem.name)

So triggering item is the motion sensor, in your case that would be the rollershutter, the value would be your light.

motion_to_lights.map
BathroomMotion_MotionAlarm_Zigbee=Bathroom
FirstFloorMotion_MotionAlarm=GatewaySwitch
Stairway1Motion=FirstStairwayLight_Power
SecondFloorMotion=SecondFloorLight
ClosetMotion=ClosetLight_Power
GangMotion=Gang
RingMotion=FrontdoorLights

2 Likes

Great idea, I am going to try that immediately!

Daniel

1 Like