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.

Alarm "clock"
#4
1/1/1 = time object
1/1/2 = output object

delta / 10 controls how smooth the transition is, 10 means 10 * 100 seconds to get from 0% to 100%.

Note that this will not work correctly if alarm is set very close to after midnight.

This can either be a resident or a scheduled script, depending how long the final transition is.

Code:
function getoffset(t)
  return t.hour * 3600 + t.min * 60 + t.sec
end

now = os.date('*t')
now = getoffset(now)

set = grp.getvalue('1/1/1')
set = getoffset(set)

if now <= set then
  delta = set - now
  val = math.floor(100 - delta / 10)
  if val > 0 then
    grp.write('1/1/2', val)
  end
end
Reply


Messages In This Thread
Alarm "clock" - by FatMax - 29.08.2017, 12:33
RE: Alarm "clock" - by admin - 29.08.2017, 12:45
RE: Alarm "clock" - by FatMax - 29.08.2017, 12:55
RE: Alarm "clock" - by admin - 29.08.2017, 13:40
RE: Alarm "clock" - by FatMax - 29.08.2017, 14:10
RE: Alarm "clock" - by admin - 29.08.2017, 15:07

Forum Jump: