sonnyboy wrote: ↑11 Oct 2019, 17:37
Är det något mera som man ska tänka på för att fungera?
får detta i loggen men inget händer.
Code: Select all
[DEBUG] 17:33:00: [true]>>'Rule:40[@17:33 & wday('mon-fri') => post(#dimLight{id=lampID,start=0,stop=99,duration=00...]'
Har bara ändrat tiden allt annat är som i ditt förslag.
Är det en dimmbar lampa?
Ser det ut såhär?
Code: Select all
function main()
:
:
do -- Dawn simulator code
equations = {
linear = function(t, b, c, d) return c * t / d + b; end,
inQuad = function(t, b, c, d) t = t / d; return c * math.pow(t, 2) + b; end,
inOutQuad = function(t, b, c, d) t = t / d * 2; return t < 1 and c / 2 * math.pow(t, 2) + b or -c / 2 * ((t - 1) * (t - 3) - 1) + b end,
outInExpo = function(t, b, c, d) return t < d / 2 and equations.outExpo(t * 2, b, c / 2, d) or equations.inExpo((t * 2) - d, b + c / 2, c / 2, d) end,
inExpo = function(t, b, c, d) return t == 0 and b or c * math.pow(2, 10 * (t / d - 1)) + b - c * 0.001 end,
outExpo = function(t, b, c, d) return t == d and b + c or c * 1.001 * (-math.pow(2, -10 * t / d) + 1) + b end,
inOutExpo = function(t, b, c, d)
if t == 0 then return b elseif t == d then return b + c end
t = t / d * 2
if t < 1 then return c / 2 * math.pow(2, 10 * (t - 1)) + b - c * 0.0005 else t = t - 1; return c / 2 * 1.0005 * (-math.pow(2, -10 * t) + 2) + b end
end,
}
Event.event({type='dimLight'},function(env)
local e,f = env.event,equations[env.event.curve] or equations['linear']
e.dir,e.start = e.dir or 1,e.start or 0
e.t = e.t or e.dir==1 and 0 or e.duration
local currV = tonumber(fibaro:getValue(e.id,"value"))
if e.v and currV ~= e.v then return end -- Someone changed the lightning, stop dimming
e.v = math.floor(f(e.t,e.start,e.stop,e.duration)+0.5)
fibaro:call(e.id,"setValue",e.v)
e.t=e.t+e.dir*e.interval
if 0 <= e.t and e.t <= e.duration then Event.post(e,os.time()+e.interval) end
end)
end
rule("@17:33 & wday('mon-fri') => post(#dimLight{id=lampID,start=0,stop=99,duration=00:20,interval=00:01,curve='outInExpo'})")
För mig tuffar den på och ändrar dim 1 gång i minuten i 20min.
rule("@17:33 & wday('mon-fri') => post(#dimLight{id=lampID,start=0,stop=99,duration=00:00:20,interval=00:00:01,curve='outInExpo'})")
Kör den på 20s med 1s steps.
Tips, om man vill testa en tidsregel direkt kan man skriva
rule("@now+2 & wday('mon-fri') => post(#dimLight...
så startar den 2 sekunder efter att scenen startat.