# Need help on flow turning lights on based on lux & motion

**URL:** <https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189>\
**Category:** Questions & Help\
**Created:** [May 15, 2019, 8:51pm UTC](https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189 "2019-05-15T20:51:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bart\_W](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bart_w/32/10545_2.png) [@Bart\_W](https://community.homey.app/u/Bart_W)\
**Post date:** [May 15, 2019, 8:51pm UTC](https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189/1 "2019-05-15T20:51:05Z")

</div>

Hi all,

I’ve been messing around with a flow to get something basic done, but can’t manage to make it work :-/

Context : A neo coolcam PIRV2 is placed in the kitchen. If it is getting dark \< 5 lux, than the lights should turn on when there is movement.

First I created a more simple flow, but I’ve been working now on another more robuust flow, that doesn’t work:

Flow a:  
If lumonisity has changed  
AND tag luminosity \< 5  
THEN set variable kitchenDARK to true

Flow b:  
If there is motion  
AND variable kitchendark is true  
THEN enable light 1 , enable light 2 and stop countdowntimer KITCHEN

Flow c:  
If there is no motion detected  
THEN start countdowntimer KITCHEN 5

Flow d:  
If Countdowntimer KITCHEN is empty  
THEN disable light 1, disable light 2

Flow e:  
If luminosity \> 10  
THEN set variable KitchenDark to False

Whats happening: it’s dark, motion sensor works, put lights won’t turn off… 😮  
Maybe it’s too late for me to work on logical flows, right now, but this is very annoying me 🙂

Has anyone a clue (or flow)…

Much appreciated,

Kind regards,

Bart

---

<div class="post-metadata">

**Author:** ![FKey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fkey/32/14793_2.png) [@FKey](https://community.homey.app/u/FKey)\
**Post date:** [May 15, 2019, 9:11pm UTC](https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189/2 "2019-05-15T21:11:26Z")

</div>

I would advice you to doenload papertrails and add logging to your flows.  
That way at least you can see what flows are triggering and what are not

Dont know the coolcam pir, but I gues it has something to do with the “no motion” flow

If you are not experienced in building flows I would advice you to take a look at the timer app  
[https://apps.athom.com/app/com.synplyworks.thenmore](https://apps.athom.com/app/com.synplyworks.thenmore)

Its an all in one, so you do not need tobother about resetting and counters.  
Just use the motion trigger you already have to trigger the timer.

---

<div class="post-metadata">

**Author:** ![neluz](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/neluz/32/8853_2.png) [@neluz](https://community.homey.app/u/neluz)\
**Post date:** [May 16, 2019, 7:34am UTC](https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189/3 "2019-05-16T07:34:35Z")

</div>

You can do it much simpeler.

Just combine the motion and the lux value in one flow:  
If motion  
And lux is \<5  
Then do something.

![49](https://us1.discourse-cdn.com/flex025/uploads/athom/original/2X/a/a8d78ea1c34340738b7cd635ebc9e4b914b28db5.png)

---

<div class="post-metadata">

**Author:** ![Rocodamelshekima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rocodamelshekima/32/8209_2.png) [@Rocodamelshekima](https://community.homey.app/u/Rocodamelshekima)\
**Post date:** [May 16, 2019, 7:46am UTC](https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189/4 "2019-05-16T07:46:49Z")

</div>

Or just start [here](https://community.homey.app/t/simple-lights-turning-on-off-based-on-motion/10889). Why reinvent the wheel again?

---

<div class="post-metadata">

**Author:** ![Bart\_W](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bart_w/32/10545_2.png) [@Bart\_W](https://community.homey.app/u/Bart_W)\
**Post date:** [May 16, 2019, 9:06am UTC](https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189/5 "2019-05-16T09:06:18Z")

</div>

That’s exactly what I used (using the timer and all) als tutorial. Thanks btw for this clear tutorial @Rocodamelshekima. But somehow, things got really weird. I use this way of working for another motion sensing bulb, and it works just fine. Something is happening in the relation between motion & lux I guess…

---

<div class="post-metadata">

**Author:** ![CyberSponk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/cybersponk/32/8334_2.png) [@CyberSponk](https://community.homey.app/u/CyberSponk)\
**Post date:** [May 16, 2019, 9:34am UTC](https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189/6 "2019-05-16T09:34:53Z")

</div>

Have some Flows similar as written by @neluz with Neo CoolcamV2-Sensors. All have a “Timer-Function” without an extra Timer-App and using Lux-Values. Working fine.

_FLOW1_  
**When** Motion-Detection On  
**And** Sensor-Lux is not greater 5  
**And** MyBulb is Off  
**Then** Turn On MyBulb

_FLOW2_  
**When** Motion-Detection Off  
**And** Sensor-Lux is greater 7  
**And** MyBulb is On  
**Then** Run Flow3 after x-Seconds

_Flow3_  
**When** Flow is triggered  
**And** Sensor-Lux is greater 7  
**And** Motion-Detection is Off  
**And** MyBulb is On  
**Then** Turn Off MyBulb

Flow2 has the “Timer-Time” (after x-Seconds). It starts Flow3 for turning MyBulb off. MyBulb will only turned off if there is a) No Motion-Detection and b) Lux-Value is greater 7.

The difference of 2 Lux (5 = On, 7 = Off) is to prevent always On and Off of MyBulb when there is e.g. fast Cloud-Movements on the Sky.

Also checking the State of MyBulb to prevent Homey always to send On or Off to the Bulb when new Movement-Detected-On or new Movement-Detected-Off (see Flow), for a better performance of Homey itself and a lower Traffic on the Network.

Using in _Flow1_ the Motion-Sensor of the Room/Area for turning On MyBulb, also in _Flow3_ to check the State of MyBulb.

In _Flow2_ using the All-Device-Card. If one of the Sensors at Home reporting Motion-Detection-Off MyBulb in e.g. Room1 will be turned Off when meanwhile the Sensor-Lux of Room1 has reached a Value greater 7 (and Motion-Detection-Off in Room1) equal where a Person is at Home (e.g. MyBulb is in Room1 and a Person is in Room2) \> Saves Energy.

So the releation between Motion and Lux is, on my Homey, working as expected.

---

<div class="post-metadata">

**Author:** ![Bart\_W](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bart_w/32/10545_2.png) [@Bart\_W](https://community.homey.app/u/Bart_W)\
**Post date:** [May 16, 2019, 5:34pm UTC](https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189/7 "2019-05-16T17:34:31Z")

</div>

Thanks for your reply @CyberSponk !!!  
Well, the problem is thats I can 't combine the tip sensors from 1 device in one flow: for example, Wegen motion-detection on, I can 't use the lux-sensor in And function. Maybe thats potje problem. Eager to know how @neluz Managed to do so

---

<div class="post-metadata">

**Author:** ![CyberSponk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/cybersponk/32/8334_2.png) [@CyberSponk](https://community.homey.app/u/CyberSponk)\
**Post date:** [May 16, 2019, 5:53pm UTC](https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189/8 "2019-05-16T17:53:02Z")

</div>

> [@Bart\_W](#):
>
> I can 't use the lux-sensor in And function

Didn’t could find/read out why you can’t use it. Motion and Lux should taken from the same Sensor?

---

<div class="post-metadata">

**Author:** ![Bart\_W](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bart_w/32/10545_2.png) [@Bart\_W](https://community.homey.app/u/Bart_W)\
**Post date:** [May 16, 2019, 5:55pm UTC](https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189/9 "2019-05-16T17:55:09Z")

</div>

Wenn ich den Bewegungssensor in einem Fluss verwende, kann ich ihn nicht mit dem Lichtsensor in demselben Fluss kombinieren

---

<div class="post-metadata">

**Author:** ![CyberSponk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/cybersponk/32/8334_2.png) [@CyberSponk](https://community.homey.app/u/CyberSponk)\
**Post date:** [May 16, 2019, 6:01pm UTC](https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189/10 "2019-05-16T18:01:24Z")

</div>

Sure, this works. In _When_ is your Motion-Sensor, in _Then_ your Bulb. What have you in _When_ and _Then_?

---

<div class="post-metadata">

**Author:** ![Bart\_W](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bart_w/32/10545_2.png) [@Bart\_W](https://community.homey.app/u/Bart_W)\
**Post date:** [May 16, 2019, 6:09pm UTC](https://community.homey.app/t/need-help-on-flow-turning-lights-on-based-on-lux-motion/13189/11 "2019-05-16T18:09:40Z")

</div>

The problem was in the THAN, but I realized I was stukje in my logic: I used the motion sensor in the when and the lux sensor in the AND. I should use a logica function reading out the density
