Light level based on ambient light

Does anyone know of a good way to control light based on ambient light? I have a couple of specific scenarios I’d like to solve:

  1. I’ll be using LED spots in some cabinets in my living room. As these are made for kitchen lighting they’re pretty bright - especially in a low ambient light situation. In order to not burn my eyes out when getting up in the night I would like to have some sort of function similar to newer mobile phones where it’ll dim the light to a comfortable level.

Any ideas on how to do this? I guess I’d need some sort of zwave light meter or something?

  1. Partially the same as above, only in reverse. I will have LED strips around the ceiling to give some light when it’s dark (unless the media center is running). I’d like them to turn on if it’s dark, but preserve power by keeping them off when they won’t contribute much.



I would love to do the same thing… Please let us know if you find an easy solution.


You could use one of the multisensors available by homeseer, aeotec, or others to determine the lux level of the room (from 0-1000) and when you run your scene to turn the lights on, just check the lux level before you set the brightness. The lower the lux, the lower your dim setting. I do something similar for my night light scene… When the lux in the room is below 10, and the multisensor detects motion, turn on the lights to 10% and turn off when the motion is no longer detected. simple.

What brand are you using? Are you using pleg or lua for the coding? I have an everspring motion sensor that was advertised as being able to read light level but I could never figure it out in UI7.

I would also be very interested in seeing how you’ve implemented this :slight_smile:

Here is one way of doing it, this script also takes the time into consideration and if its after midnight it will only dim the lights to 5%. Needless to say, dont forget to change the device ID’s

local Light_Status = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”, “Status”, 50)
local Light_level = luup.variable_get(“urn:micasaverde-com:serviceId:LightSensor1”, “CurrentLevel”, 7)

local t =‘*t’)
local current_second = t.hour * 3600 + t.min * 60 + t.sec – number of seconds since midnight
local min_time_in_seconds = 0 * 3600 + 1 * 60 – 00:01
local max_time_in_seconds = 6 * 3600 + 15 * 60 – 06:0

if tonumber(Light_level) < 3 then
– If between 00:01 and 06:00 dim to 5%
if (current_second > min_time_in_seconds) and (current_second < max_time_in_seconds) then
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “5”}, 50)
luup.call_action(“urn:upnp-org:serviceId:Dimming1”, “SetLoadLevelTarget”, {newLoadlevelTarget = “20”}, 50)

elseif tonumber(Light_level) > 2 and tonumber(Light_level) < 10 then

luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "30"}, 50)

elseif tonumber(Light_level) > 9 and tonumber(Light_level) < 20 then

luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "50"}, 50)

elseif tonumber(Light_level) > 19 and light_level < 35 then

luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "70"}, 50)


blingal pretty much summed it up… Just make sure you add some additional smarts to the script… like if the light is already on, don’t change the brightness as this could annoy someone walking through the room. In my case, I have two motion sensors I need to keep track of (one in the kitchen and one in the family room), so i’ve moved to using timers. When either are tripped, make sure the light is on and reset/stop the timer. When no motion is detected in 30sec, start the timer. When the timer has elapsed, turn the light off. I have another trigger watching the light state. If the light turns off while the timer is running, I disable the motion sensors for 2.5 hours (think like you’re watching a movie and don’t want to be disturbed if you have to get up for popcorn) Hope this helps

Blingal… what brand sensor are you using?


I bought a sensor, but cannot figure out how to get it to work. The retailer told me it was “generation 5” and that it might not be compatible. It’ll send update once per 24 hours, but nothing more…sucks :S

Im using a Fibaro motion sensor, its a light, motion and temp sensor Home Automation - Smart Home | FIBARO

Most people that have tried to use Ambient Light Level in their logic have been disappointed.

In most of the multi-sensor devices, the Light Level measurement is an aux sensor.
So this info is sent to Vera only when a motion is detected … or some predefined wakeup interval, which is usually lengthy in order to conserve the batteries.

In the case of motion … it can trigger your logic before it even unpacks the light level … so you have to delay the motion action before you try to access the light level.

You are better off basing your logic on time of day!