- Spoiler: show
Start script after specific sunrise time
Moderator: leecollings
-
- Posts: 60
- Joined: Tuesday 11 August 2015 14:20
- Target OS: NAS (Synology & others)
- Domoticz version: 2024.7
- Location: The Netherlands
- Contact:
Start script after specific sunrise time
Is it possible to execute this script when the sunrise is after 6:50?
-
- Posts: 648
- Joined: Saturday 21 September 2019 17:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.1
- Location: The Netherlands
- Contact:
Re: Start script after specific sunrise time
So you want to take some action betweeb 6:30 and 7:15 but only if sunrise is after 6:50?
I would then trigger the script with the between 6:30 and 7:15 condition and then in the script test whether sunrise is after 6:50 before doing any further action.
I see in the dzVents wiki there is a "sunriseInMinutes" time property, so you should be able to use that for the 6:50 sunrise test.
https://www.domoticz.com/wiki/DzVents:_ ... _scripting
I would then trigger the script with the between 6:30 and 7:15 condition and then in the script test whether sunrise is after 6:50 before doing any further action.
I see in the dzVents wiki there is a "sunriseInMinutes" time property, so you should be able to use that for the 6:50 sunrise test.
https://www.domoticz.com/wiki/DzVents:_ ... _scripting
-
- Posts: 356
- Joined: Saturday 27 February 2016 0:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Contact:
Re: Start script after specific sunrise time
Try with an uppercase "I" in "sunriseInMinute" (things are case sensitive).
-
- Posts: 60
- Joined: Tuesday 11 August 2015 14:20
- Target OS: NAS (Synology & others)
- Domoticz version: 2024.7
- Location: The Netherlands
- Contact:
Re: Start script after specific sunrise time
Correct and that has been tested but I got the error "attempt to index a nil value (field 'sunriseinMinutes')".willemd wrote: ↑Tuesday 03 September 2024 10:59 So you want to take some action betweeb 6:30 and 7:15 but only if sunrise is after 6:50?
I would then trigger the script with the between 6:30 and 7:15 condition and then in the script test whether sunrise is after 6:50 before doing any further action.
I see in the dzVents wiki there is a "sunriseInMinutes" time property, so you should be able to use that for the 6:50 sunrise test.
https://www.domoticz.com/wiki/DzVents:_ ... _scripting
But FlyingDomotic got a excelent point

Made the change and I will see what happens tomorrow morning.FlyingDomotic wrote: ↑Tuesday 03 September 2024 12:28 Try with an uppercase "I" in "sunriseInMinute" (things are case sensitive).
- habahabahaba
- Posts: 233
- Joined: Saturday 18 March 2023 14:44
- Target OS: Windows
- Domoticz version: 2024.4
- Contact:
Re: Start script after specific sunrise time
Code: Select all
execute = function(domoticz, trigger)
local currentDate = os.time()
local setTime1 = '06:30'
local time1 = os.date("%Y-%m-%d "..setTime1, currentDate)
local time1toStamp = domoticz.time.dateToTimestamp(time1)
local setTime2 = '07:15'
local time2 = os.date("%Y-%m-%d "..setTime2, currentDate)
local time2toStamp = domoticz.time.dateToTimestamp(time2)
local minutesToSunrise = domoticz.time.sunriseInMinutes
local time3 = os.date("%Y-%m-%d 00:00", currentDate)
local CurrentSunriseTimeStamp = domoticz.time.dateToTimestamp(time3) + minutesToSunrise * 60
local todaySunriseTime = domoticz.time.timestampToDate(CurrentSunriseTimeStamp,'%Y-%m-%d time')
domoticz.log('time 1 stamp: '.. time1toStamp, domoticz.LOG_ERROR)
domoticz.log('Time1: '.. time1, domoticz.LOG_ERROR)
domoticz.log('time 2 Stamp: '.. time2toStamp, domoticz.LOG_ERROR)
domoticz.log('time2: '.. time2, domoticz.LOG_ERROR)
domoticz.log('CurrentSunriseTimeStamp: '.. CurrentSunriseTimeStamp, domoticz.LOG_ERROR)
domoticz.log('todaySunriseTime: '.. todaySunriseTime, domoticz.LOG_ERROR)
if CurrentSunriseTimeStamp > time1toStamp and CurrentSunriseTimeStamp < time2toStamp then
domoticz.log('Its MATCH!!!', domoticz.LOG_ERROR)
end
end
Who is online
Users browsing this forum: No registered users and 1 guest