This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Grow light time control script
#1
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?

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
Reply


Messages In This Thread
Grow light time control script - by clue9 - 29.04.2023, 23:19
RE: Grow light time control script - by clue9 - 30.04.2023, 22:49
RE: Grow light time control script - by admin - 01.05.2023, 07:43
RE: Grow light time control script - by clue9 - 01.05.2023, 09:53
RE: Grow light time control script - by admin - 01.05.2023, 10:29
RE: Grow light time control script - by clue9 - 01.05.2023, 20:19

Forum Jump: