turning an lamp slowly on

Moderator: leecollings

Post Reply
janjansen
Posts: 3
Joined: Saturday 22 June 2024 10:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

turning an lamp slowly on

Post 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
Attachments
Knipsel.PNG
Knipsel.PNG (12.32 KiB) Viewed 1015 times
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: turning an lamp slowly on

Post by waltervl »

For a dzvents script you can check this topic https://www.domoticz.com/forum/viewtopic.php?t=33412
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
psubiaco
Posts: 194
Joined: Monday 20 August 2018 9:38
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Italy
Contact:

Re: turning an lamp slowly on

Post 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%
Paolo
--
I use DomBus modules to charge EV car, get a full alarm system, control heat pump, fire alarm detection, lights and much more. Video
Facebook page - Youtube channel
janjansen
Posts: 3
Joined: Saturday 22 June 2024 10:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: turning an lamp slowly on

Post by janjansen »

i think this would work
Last edited by janjansen on Saturday 22 June 2024 12:02, edited 1 time in total.
janjansen
Posts: 3
Joined: Saturday 22 June 2024 10:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: turning an lamp slowly on

Post by janjansen »

waltervl wrote: Saturday 22 June 2024 11:09 For a dzvents script you can check this topic https://www.domoticz.com/forum/viewtopic.php?t=33412
yes it works!
Kedi
Posts: 536
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: turning an lamp slowly on

Post 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.
Logic will get you from A to B. Imagination will take you everywhere.
janpep
Posts: 212
Joined: Thursday 14 March 2024 10:11
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: turning an lamp slowly on

Post 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.
Domoticz in Ubuntu virtual machine on Synology DS718+ behind FRITZ!Box.
Using: EvoHome; MELCloud; P1 meter; Z-Stick GEN5; Z-Wave-js-ui; MQTT; Greenwave powernodes 1+6; Fibaro switch, plugs, smoke; FRITZ!DECT 200. Scripts listed in profile interests.
janpep
Posts: 212
Joined: Thursday 14 March 2024 10:11
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: turning an lamp slowly on

Post by janpep »

PS. Your while with sleep wil not work anyway, because the script can not run for more than 10 seconds.
Domoticz in Ubuntu virtual machine on Synology DS718+ behind FRITZ!Box.
Using: EvoHome; MELCloud; P1 meter; Z-Stick GEN5; Z-Wave-js-ui; MQTT; Greenwave powernodes 1+6; Fibaro switch, plugs, smoke; FRITZ!DECT 200. Scripts listed in profile interests.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest