This object is in archive! 

Motion / luminance based lighting

Guest shared this question 7 years ago
Need Answer

Folks,


I need some help on getting this work. I know it's a topic many of you have come across, and despite looking at many examples I do not seem to be getting this right - and I do not understand why.


I have 4 multisensors installed. One is outside to measure luminance, the other 3 are in the living room ('Woonkamer') and are used to measure presence (motion). The idea is simple: if luminance is below a certain value, AND there is motion in the living room, switch the lights on. If there is no more motion, switch the lights off.


I'm trying to achieve this by having two rules

1. One that sets the variable 'woonkamer' to 1 whenever there is motion, and to 0 when there is no motion

2. One that switches the lights in the living room on if the variable 'woonkamer'=1 and luminance from one of the sensors <= 150 lux


Both rules are attached. I'd greatly appreciated if you can have a look to point at what I'm doing wrong in this.

Replies (6)

photo
2

You should do it the other way round: Your luminance rule only runs, when there is a change in the luminance AND it is below 150. Place the variable in the luminance rule and the light switching in the movement rule. The movement rule is triggered whenever there is movement.


Better still, use only on rule as follows:


When movement=any

If movement=on and luminance<150

Switch on

Else

Switch off

photo
1

Hmmm. So I should do it the other way around. But why? It appears I have a serious issue understanding the logic of how Zipato has designed this. My rule says:

WHEN luminance < 150

IF movement=on

Switch on

Else

Switch off

In my view, the result should be the same. With the difference being, that I would expect my code ONLY to run if it's dark, where code posted above is always evaluated even when it's light (which seems inefficient). But my code doesn't work, so I must be misinterpreting how the Zipate Rules work.

What I particularly have trouble grasping is why you are writing the 'WHEN movement=any' at the top? Why is that. And to what sensors should it relate, all 3 living room sensors or just one?


Finally, I was wondering: will in your example the rule also switch the lights OFF when luminance comes above 150 while you are in the living room?

photo
1

In my opinion Zipato "waits" for the first WHEN condition and then executes the whole rule. So with "WHEN luminance < 150 " the rule triggers every time, the luminance goes from 150 to 149 or less. I´m not even sure if "WHEN luminance < 150" triggers anything but if it does, it only executes the rule once when the light goes down. During the night, when it is dark, the rule won´t do anything. So better use Tims approach (I´ve attached an example which I would try)


Klaus

photo
1

Exactly. WHEN might be a bit misleading at first, since the rule is only run one time once the light goes below 150. Since you want something to happen "when" your motion sensor sense motion, start your rule with them.

photo
photo
1

I have now updated the rules as follows. Personally, I'd welcome any suggestions to make this more workable/readable, in short: more elegant code (as I find it horrific and hard to understand this way). But would this work?

photo
1

I would do it this way:


  1. WHEN motionsensor1 = ANY OR motionsensor2 = ANY OR motionsensor3 = ANY
  2. IF aeonsensor LUX <= 150
  3. JOIN
  4. IF motionsensor1 = MOTION OR motionsensor2 = MOTION OR motionsensor3 = MOTION
  5. turn lights/scene on
  6. ELSE
  7. WAIT 600 (this is optional, maybe your sensors have a cancelation delay anyway)
  8. turn lights/scene off

Greetings to the NL,

Jan

photo
1

Thanks @Jan & @Tim - this has been a great help. I've fiddled quite a bit with this. In the end I now have a working setup with two virtual switches:


1. Presence living room

Switch is set to ON when one of the three motion sensors is tripped, to OFF if all three state no motion


2. Daylight

Switch is set to ON when luminance from the sensor outside exceeds 150 lumen, to OFF otherwise.


Rule to switch the lights on then as follows:


WHEN 'Presence living room' ANY OR 'Daylight' ANY

IF 'Presence living room' ON AND 'Daylight' OFF

'Lights living room on' RUN SCENE

ELSE

'Lights living room off' RUN SCENE


That's it. Works like a charm, were it not that one of the 3 motion sensors (Aeotec Multisensor 6) does not properly detect motion (ceiling mounted setup). Other sensors (Aeotec Multisensor 5) work fine.


@Jan - looking at your rule I suspect it would not turn on the lights when you are already at home and it turns dark. For that, you also need to include the luminance sensor in the WHEN statement, at least if my understanding is now correct.

photo
1

Yes, that's correct.

Leave a Comment
 
Attach a file