Convert sunset as $
Posted: Wednesday 31 March 2021 10:47
Hi,
Need to convert sunset as a $ as 20:30 f.I.
Search the wiki, but can’t find it.
Need to convert sunset as a $ as 20:30 f.I.
Search the wiki, but can’t find it.
Code: Select all
local onTime = 'sunset'
local ofTime = '23:00'
local printerTime = '09:00'
commandArray = {}
if os.date('%H:%M') >= onTime and os.date('%H:%M') <= ofTime then
if otherdevices['Wie is er thuis'] == 'Off' then
print ("We zijn NIET thuis")
Dickey wrote: ↑Wednesday 31 March 2021 12:23 Hi waaren,
Thanks for you're answer. This is a part of the code.
Want to have a action between 2 different moments.
Code: Select all
local onTime = 'sunset' local ofTime = '23:00' local printerTime = '09:00' commandArray = {} if os.date('%H:%M') >= onTime and os.date('%H:%M') <= ofTime then if otherdevices['Wie is er thuis'] == 'Off' then print ("We zijn NIET thuis")
Code: Select all
commandArray = {}
local onTime = _G.timeofday.SunsetInMinutes -- sunset as minutes since midnight
local now = os.date('%H') * 60 + os.date('%M') -- now in minutes since midnight
local ofTime = '23:00'
local printerTime = '09:00'
if now >= onTime and os.date('%H:%M') <= ofTime then
if otherdevices['Wie is er thuis'] == 'Off' then
print ("We zijn NIET thuis")
end
end
return commandArray
Code: Select all
local function minutesToTime(minutes)
local h = math.floor(minutes / 60)
local hh = ('0' .. h):sub(-2)
local mm = ('0' .. minutes - (h * 60)):sub(-2)
return hh .. ':' .. mm
end
commandArray = {}
local onTime = minutesToTime(_G.timeofday.SunsetInMinutes) -- sunset as hh:mm
print(onTime)
local ofTime = '23:00'
local printerTime = '09:00'
if os.date('%H:%M') >= onTime and os.date('%H:%M') <= ofTime then
if otherdevices['Wie is er thuis'] == 'Off' then
print ("We zijn NIET thuis")
end
end
return commandArray
Code: Select all
local ofTime = '23:00'
local printerTime = '09:00'
local function minutesToTime(minutes)
local h = math.floor(minutes / 60)
local hh = ('0' .. h):sub(-2)
local mm = ('0' .. minutes - (h * 60)):sub(-2)
return hh .. ':' .. mm
end
commandArray = {}
local onTime = minutesToTime(_G.timeofday.SunsetInMinutes) -- sunset as hh:mm
if now >= onTime and os.date('%H:%M') <= ofTime then
if otherdevices['Wie is er thuis'] == 'Off' then
print ("We zijn NIET thuis")
commandArray['Group:Hoofdverlichting']='Inactive'