Page 1 of 1

Seconds between midnight and sunset

Posted: Monday 04 December 2017 22:33
by tonse
I need to send a command to an espeasy device. It consist of the starttime and the duration. That way the espeasy can handle the "off" command by itself. This feels more secure then sending the "off" command separate. If that command is missed, the pump will keep on running in my pool

So i need the seconds between sunset and midnight

I tried the code below. I got stuck with the Time property. I do not know where to go or which function to use.
SunsetToMidnight is a uservariable

Code: Select all

return {

	active = true, 

on = {
        timer = {'60 minutes before sunset'}
    },
	execute = function(domoticz,dummy)
	    local Time = require('Time')
local tA = Time('00:00:00')
local tB = Time('sunset')

print(tB.compare(tA).secs) 
	  
	    domoticz.variables('SunsetToMidnight').set(2378)
	   
	
	end

}

Re: Seconds between midnight and sunset

Posted: Tuesday 05 December 2017 9:13
by dannybloe
Time('sunset') doesn't work. You need to pass a valid time.

I guess you meant to do this:

Code: Select all

local seconds = (24 * 3600) - domoticz.time.sunsetInMinutes * 60
See domoticz.time.