Hi,
Is it possible to trigger a script (x) minutes before sunset?
I have some lights which I switch on at sunset. Sometimes it's already dusk so I would like to switch them a little earlier.
I could create a dummy switch with a timer, but I was wondering if this can also be done with Dzvents timer trigger.
Timer (x) minutes before sunset
Moderator: leecollings
-
- Posts: 69
- Joined: Friday 23 June 2017 9:27
- Target OS: Linux
- Domoticz version: 2024.4
- Location: The Netherlands
- Contact:
Re: Timer (x) minutes before sunset
I use this in my Dzvents-script.
Basically LUA what Dzvents basically is as I understood.
Hope this helps
Basically LUA what Dzvents basically is as I understood.
Code: Select all
-- Only let the lights switch on if they are within a set time before sunset
local HoursNow = tonumber(os.date("%H"));
local MinutesNow = tonumber(os.date("%M"));
local TimeInMinutesNow = MinutesNow + HoursNow * 60
local SetTimeBeforeSunset = timeofday['SunsetInMinutes']-150 -- 2 1/2 hour before sunset (150 minutes)
if ( ......blablabla.... and (TimeInMinutesNow > SetTimeBeforeSunset) and .....blabla.........) then
.............
-
- Posts: 21
- Joined: Sunday 05 February 2017 12:09
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Model 3
- Contact:
Re: Timer (x) minutes before sunset
my method.
return {
active = true,
on = {
timer = { '65 minutes before sunset'}
},
execute = function(domoticz)
if domoticz.time.matchesRule('65 minutes before sunset') then
domoticz.devices('Light Switch').switchOn().forMin(320)
end
return {
active = true,
on = {
timer = { '65 minutes before sunset'}
},
execute = function(domoticz)
if domoticz.time.matchesRule('65 minutes before sunset') then
domoticz.devices('Light Switch').switchOn().forMin(320)
end
Translated with google
-
- Posts: 67
- Joined: Saturday 17 June 2017 12:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: Timer (x) minutes before sunset
Please see the wiki page on DzVents as it offers many options to simplify you LUA scripts. For e.g. for the timers functions where with LUA you had to do calculations.
http://www.domoticz.com/wiki/DzVents:_n ... er_options
Just add one of the many timer options in the timer section : 'xx minutes before sunset', 'xx minutes after sunset', 'xx minutes before sunrise', 'xx minutes after sunrise'
My script for sunset
http://www.domoticz.com/wiki/DzVents:_n ... er_options
Just add one of the many timer options in the timer section : 'xx minutes before sunset', 'xx minutes after sunset', 'xx minutes before sunrise', 'xx minutes after sunrise'
My script for sunset
- Spoiler: show
-
- Posts: 858
- Joined: Sunday 23 February 2014 17:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: mixed
- Location: Hengelo(Ov)/NL
- Contact:
Re: Timer (x) minutes before sunset
Simplest is to use the Timer linked to a Switch.
Go to Dashboard/ Switches, select the desired Switch, select Timers, and then you have plenty of choices, relative to fixed clocktime, relative to sunrise, relative to sunset, related to certain days, incl./excl. ambiguity, etc.
Go to Dashboard/ Switches, select the desired Switch, select Timers, and then you have plenty of choices, relative to fixed clocktime, relative to sunrise, relative to sunset, related to certain days, incl./excl. ambiguity, etc.
Last edited by Toulon7559 on Wednesday 30 August 2017 15:36, edited 1 time in total.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
-
- Posts: 11
- Joined: Thursday 23 July 2015 11:42
- Target OS: Linux
- Domoticz version: v4.9701
- Location: The Netherlands
- Contact:
Re: Timer (x) minutes before sunset
I've read the manual, but I totally missed the 'xx minutes before sunrise' part.
Thanks for all the help!
Thanks for all the help!
Who is online
Users browsing this forum: No registered users and 1 guest