Fix Dimming at certain time of a day

Hi together,

Actually:
I have a dimmer. When I swith on, it goes automatically to 100%.

What I wish:
Between 20h00 and 22h30, at a certain day, when i switch on, it goes automatically to 35%

I try to programm (UI4), when dimmer event is ‘on’ go to 35% and it works well but when I switch a second time the dimmer it can go to 100% because the first event was dimmer is on and the state doent change …

How can I programm in Lula Code: whenn dimmer >35% then go to 35% and include the condition of the time?

Thanks for your reply,

Chris

I will share what I have, I hope it helps.

My setup is based on a camera on my son’s crib that picks up his movement in the middle of the night and turns on lamp connected to a GE45602 for 10 minutes than turns it back off. I check to see if the time is between 6am and 10pm and if so then turn on the lamp and set the brightness to 100% else set the brightness to 30%.

To get this to work I use the Motion sensor on the Camera that triggers the “Baby Light On” Scene where the code below is in, Countdown Timer that starts when the light is turned on and the complete triggers the “Baby Off Light” Scene. At the end I reset the Motion Sensor tripped flag so that if my wife is still changing the baby or putting him down it resets the 10 minute timer.

-- Find the status of the light
local service_id = "urn:upnp-org:serviceId:Dimming1"
local light_status = luup.variable_get(service_id,"LoadLevelStatus", 26)

-- Get the current hour and delay time
local t = os.date('*t')
local current_hour = t.hour

-- Set Hour for Hight Light Levels
local light_high_min = 6
local light_high_max = 20

-- Reset Motion Senson on Baby Camera
function ResetMotionSensor()
    luup.variable_set("urn:micasaverde-com:serviceId:SecuritySensor1","Tripped","0",12)
end

-- Check time to see if we should turn the lights on to 100%
if (current_hour >= light_high_min) and (current_hour <= light_high_max) then
    luup.call_action(service_id, "SetLoadLevelTarget", {newLoadlevelTarget = "100"}, 26)  

-- Check to make sure the light was not manually turned on before dimming to 30%
elseif (tonumber(light_status) < 30) then
    luup.call_action(service_id, "SetLoadLevelTarget", {newLoadlevelTarget = "30"}, 26)  

end

-- luup.call_delay("ResetMotionSensor", 30)

return true

Make note that depending on the dimmer, this will not work well when the switch is pressed manually. Meaning if the dimmer does not report instand status, the dimmer will not dim to the proper level defined in your scene.

  • Garrett

Hi,

Thanks for help,

I do following scene:

local service_id = “urn:upnp-org:serviceId:Dimming1”
local dim_status = luup.variable_get(service_id,“LoadLevelStatus”, 118)

if (tonumber(dim_status) > 31) then
luup.call_action(service_id, “SetLoadLevelTarget”, {newLoadlevelTarget = “30”}, 118)

end

the scene works when activate manually, and the dimmer send back the right dimmposition to vera, when change manual on the switch.

How can I do to activateautomatically the scene when the dimmer is up to 31%?

Thanks for reply

Hi,

I apply an event an this luup, do the scene every minutes.
And the scene works fine but every minutes.

1/ Is it possible to activate the scene every second, or always (every 0,1s)?

2/ How is it possible to create an event in a scene like this:

local dim_status = luup.variable_get(service_id,“LoadLevelStatus”, 118)
if (tonumber(dim_status) > 31) then
return true
else return false
end

----if the dimmer is over 31% then the scene is active----

Thanks for your help,

Chris

1/ Is it possible to activate the scene every second, or always (every 0,1s)?
The luup internal timer can schedule at a 1 second interval ... But that eats up a lot of processing time! That's probably why MCV did not bring this out to the user interface.
2/ How is it possible to create an event in a scene like this:
Actually your LUUP code does not create an event. An event happens (timer or trigger). You can put code in the LUUP tab for the scene that causes the timer or trigger to be ignored. If the code returns TRUE or does not return anything than it proceeds to execute the commands (and delayed commands) for your scene.

http://forum.micasaverde.com/index.php/topic,13105.0.html