Hi.
My soulmate is working with plants these days, and wants ligths to turn on and off in specified times of day.
I try to make a script to make here able to automate and decide this from Moasic.
Created 2 virtual groupadresses for on and off time (hh:mm), and made a time widget in Moasic for her to change times at her own will..
Group adresses is formatted as 3byte time/date.
Then I wrote this resident script to run every 60 seconds.
But it fails in many ways. I tried to log output but get errors.
Someone want to help out?
Could it be different time formats? first log entry returns a nil value, so why is it not reading my object data?
My soulmate is working with plants these days, and wants ligths to turn on and off in specified times of day.
I try to make a script to make here able to automate and decide this from Moasic.
Created 2 virtual groupadresses for on and off time (hh:mm), and made a time widget in Moasic for her to change times at her own will..
Group adresses is formatted as 3byte time/date.
Then I wrote this resident script to run every 60 seconds.
But it fails in many ways. I tried to log output but get errors.
Someone want to help out?
Could it be different time formats? first log entry returns a nil value, so why is it not reading my object data?
Code:
on_time = grp.getvalue('31/1/13')
off_time = grp.getvalue('31/1/14')
--log entry to confirm data is read
log(on_time)
log(on_time)
--log state of light to confirm change
lightstate = grp.getvalue('31/1/17')
log('Light turned off at ' .. os.date('%H:%M:%S') .. ' set to' ..ligthstate)
-- time set as hour and minute. Seconds never used when set, will always be 00, datatype is 3 byte time/day this is tested ok.
--as time is set by only hour and minute and seconds is never set in the on and off times, seconds have to be equal 00 when comparing. (3 byte time/day)
if os.date('%H:%M:00') == on_time then
grp.write('31/1/15', true)
--log state of light to confirm change
lightstate = grp.getvalue('31/1/17')
log("Light turned on at " .. os.date('%H:%M:%S') .. 'set to' ..lightstate)
elseif os.date('%H:%M:00') == off_time then
grp.write('31/1/15', false)
--log state of light to confirm change
lightstate = grp.getvalue('31/1/17')
log('Light turned off at ' .. os.date('%H:%M:%S') .. ' set to' ..ligthstate)
end