Turn on lights when there is movement and luminosity is low

My garage is completely dark when the garage gate is closed, but enough light may come in when the garage gate open (unless it is at night, of course).

Sometimes, I keep the gate open for hours while I am doing things inside the garage, and I didn’t like the idea of light being on all the time because there is motion, so I decided to use a light sensor.

I have implemented a system that will turn light on when there is motion in the garage and luminosity is low, and will turn it off as soon as there is no motion or luminosity is high (for example, if the garage gate has open)

Devices

I have installed the following Tuya-compatible devices:




Conditions

Conditions for light sensor

In Apilio, I have two conditions for the light sensor:

  • LuminosidadAltaGaraje (HighLuminosityInGarage) => Bright value must be greater than 50 lux
  • LuminosidadBajaGaraje (LowLuminosityInGarage) => Bright value must be lower than 30 lux

Reason for setting different thresholds (>50 and <30) rather than (>50 and <50) is that I don’t want lights to turn on and off continuously due to slight variations in luminosity: 49 - 50 - 51 - 50 - 49 - 48 etc.

:bulb: Tip: It is important to put the light sensor near the gate so it captures a lot of light from the outside when the gate is open, and threshold for high luminosity can be quite high (e.g. 50 lux). Otherwise, if threshold is too low, the garage lights will make the light sensor to detect enough light, and you will enter an endless loop: luminosity is low > turn on lights > luminosity is high > turn off lights > luminosity is low > turn on lights > …

Conditions for motion sensors

I have conditions for each motion sensor detecting motion:

  • PIR1Movimiento (PIR1WithMotion)
  • PIR2Movimiento (PIR2WithMotion)
  • PIR3Movimiento (PIR3WithMotion)
  • PIR4Movimiento (PIR4WithMotion)

Example of one of these conditions (all four are the same):

And also 4 conditions for each motion sensor not detecting motion for 1 minute:

  • PIR1SinMovimiento (PIR1WithoutMotion)
  • PIR2SinMovimiento (PIR2WithoutMotion)
  • PIR3SinMovimiento (PIR3WithoutMotion)
  • PIR4SinMovimiento (PIR4WithoutMotion)

Example of one of these conditions (all four are the same):


Logicblocks

Logicblock 1. Turn on light if low luminosity and motion is detected

This logicblock turns the smart switch on via Tuya/SmartLife when any sensor detects motion and luminosity is low.

The condition is quite simple: LowLuminosityInGarage AND (PIR1WithMotion OR PIR2WithMotion OR PIR3WithMotion OR PIR4WithMotion)

Logicblock 2. Turn off light if no motion has been detected for 1 minute

This logicblock turns the smart switch off via Tuya/SmartLife when all sensors do not detect motion for 1 minute.

Logicblock 3. Turn off light if luminosity is high

This logicblock turns the smart switch off via Tuya/SmartLife when luminosity is high, regardless of whether there is motion or not.

🎁 Bonus

Since LuminosidadAltaGaraje (HighLuminosityInGarage) and LuminosidadBajaGaraje (LowLuminosityInGarage) are Trigger conditions, light turns off as soon as the gate door opens and sun light enters. Lights also turn on as soon as gate closes and there is darkness. This is very useful when I am entering or going out with the car :red_car::dash:

5 Likes

A Zigbee light sensor that i have been looking for as the wifi one I have is bleh

Thanks great set up

2 Likes

This one works fine and integrates with Apilio perfectly although it is not very sensitive in low light (it reports 0 lux even if it is not completely dark).

2 Likes

Thanks for this details article! Very smart and crafty :nerd_face: 🪄

2 Likes

Hey I have a spare you can try if you like but it generates a lot of noise!

Thanks I have put some on order now :slight_smile:

1 Like