Page 1 of 1

automatic time daylight

Posted: Sunday 09 December 2018 12:07
by bce626
Hi, my name is Brian
this is my first post and my first script.
I am from the Netherlands, and have trying to create een time script that turns my light on 30 minutes before sun set, automatically with DzVents (time)script

if have a raspberry pi 1b
os is Debian
Domoticz version 4.9700
443,92 MHz device

the log creates the following text

2018-12-09 11:49:00.923 Status: dzVents: Info: ------ Start internal script: auto_verlichting:, trigger: every minute
2018-12-09 11:49:00.924 Status: dzVents: Error (2.4.6): An error occurred when calling event handler auto_verlichting
2018-12-09 11:49:00.925 Status: dzVents: Error (2.4.6): ...z/scripts/dzVents/generated_scripts/auto_verlichting.lua:16: attempt to index global 'kleuren_led_woonkamer' (a nil value)
2018-12-09 11:49:00.925 Status: dzVents: Info: ------ Finished auto_verlichting


can someone help me with this or tell me if it is possible at all?


Spoiler: show
return { on = {
['timer'] = {
'every minute'
},
{
['devices'] = {'kleuren_led_woonkamer'}
}
},
execute = function(domoticz, dummy)

-- get current time
timenow = os.date("*t")
minutesnow = timenow.min + timenow.hour * 60

if (minutesnow <= timeofday['SunsetInMinutes'] - 30 ) then
kleuren_led_woonkamer.on(14)
end
end
}

Re: automatic time daylight

Posted: Sunday 09 December 2018 13:04
by SweetPants
Can you give this a try?

Code: Select all

return { 
	on = {
		timer = {
			'30 minutes before sunset'
		},
	},
		
	execute = function(domoticz, item, triggerinfo)
		
		domoticz.devices('kleuren_led_woonkamer').switchOn()
		
	end
}
Have you checked https://www.domoticz.com/wiki/DzVents:_ ... _scripting

Re: automatic time daylight

Posted: Sunday 09 December 2018 14:03
by bce626
To be honest I havened check that page, I did a search the internet and found a lua/ DzVents page, wits explain basic scripting Lua.
and I start playing with it.

thank you for reacting to my post, I have copied it into Domoticz I will let you know if it works
PS: I change one small thing in the scrip "' kleuren_led_woonkamer'} " to 'kleuren_led_woonkamer')

Re: automatic time daylight

Posted: Sunday 09 December 2018 14:51
by SweetPants
bce626 wrote: Sunday 09 December 2018 14:03 To be honest I havened check that page, I did a search the internet and found a lua/ DzVents page, wits explain basic scripting Lua.
and I start playing with it.

thank you for reacting to my post, I have copied it into Domoticz I will let you know if it works
PS: I change one small thing in the scrip "' kleuren_led_woonkamer'} " to 'kleuren_led_woonkamer')
Yeah, that was a typo, Could not check the script yet.

Re: automatic time daylight

Posted: Monday 10 December 2018 17:39
by bce626
SweetPants, thank you, it's working like a charm.
:)

Re: automatic time daylight

Posted: Monday 10 December 2018 19:06
by SweetPants
bce626 wrote: Monday 10 December 2018 17:39 SweetPants, thank you, it's working like a charm.
:)
You are welcome