Page 1 of 1
turning an lamp slowly on
Posted: Saturday 22 June 2024 10:39
by janjansen
Hi everybody
I want to switch on a lamp very slowly at 6:30 in the morning, and by that I mean that it starts at 1 percent and then burns at about 90 percent after 10 minutes.
I've tried a lot but nothing works for me.
Below I have posted the program I have now written to give you an idea of what I mean.
("Jan wakkerworden" is an dummy switch that goes on at 6:30.)
thanks in advance,
Jan
Re: turning an lamp slowly on
Posted: Saturday 22 June 2024 11:09
by waltervl
Re: turning an lamp slowly on
Posted: Saturday 22 June 2024 11:26
by psubiaco
Don't use the sleep inside a script!
If you want a light to be 100% in 10 minutes, I suggest to call a script every minute
script_time_turnOnLight.lua
so if time>=6:30 and current dimmer value <100%, set dimmer to current value + 10%
Re: turning an lamp slowly on
Posted: Saturday 22 June 2024 11:46
by janjansen
i think this would work
Re: turning an lamp slowly on
Posted: Saturday 22 June 2024 12:01
by janjansen
Re: turning an lamp slowly on
Posted: Saturday 22 June 2024 14:56
by Kedi
If you have Zigbee light bulbs then most of those bulb support "transition"
In a dzVents script you set transition to 60 and when you turn the lamp on it goes from 0% to whatever you have set to On position in 60 seconds.
So in dzVents only 2 commands to get it done.
Re: turning an lamp slowly on
Posted: Saturday 22 June 2024 21:10
by janpep
janjansen wrote: Saturday 22 June 2024 10:39
I've tried a lot but nothing works for me.
When nothing works for you, you maybe do not mind that I created something in dzVents.
I think this goes in the direction of what you want?
Adapted from my t_airplanes script,where I wanted an action every xx seconds.
1. triggers on a change of your 'Jan Wakkerworden' device.
2. Checks if it is on.
3. loops from 1 to 600 seconds = 10 minutes. Schedules it with 100 steps of 6 second interval.
4. Every time sets the level 1 higher. So should end up at 100% if I am right.
NB. untested.
Code: Select all
--22-06-2024- Jan Peppink, https://ict.peppink.nl
return {
on = {
devices = {
'Jan Wakkerworden',
},
},
logging = {
-- Level can be domoticz.LOG_INFO, domoicz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG, domoticz.LOG_ERROR or domoticz.LOG_FORCE
--level = domoticz.LOG_INFO,
level = domoticz.LOG_DEBUG,
marker = "SlowLampIncrease-"
},
execute = function( dz, triggeredItem )
if ( triggeredItem.state == 'On' ) then
local loopCounter = 0
--Turn on hanglamp slowly
--10 minutes = 600 seconds. So from 1 to 600 step 6 seconds.
for seconds = 1, 600, 6 do
--increase loopCounter
loopCounter = loopCounter + 1
dz.log( 'Increase level to ' .. loopCounter, dz.LOG_DEBUG)
-- increase dimlevel.
dz.devices('Jan hanglamp').dimTo(loopCounter).afterSec(seconds) -- Set yourlevel 1 step higher.
end
end
end
}
-- That's All --------------------------------------------------
EDIT: Changed the loopCounter. Made little mistake. It should start with 0 always and does not have to be in persistant data, because it goes in one run.
Re: turning an lamp slowly on
Posted: Saturday 22 June 2024 21:29
by janpep
PS. Your while with sleep wil not work anyway, because the script can not run for more than 10 seconds.