Sida 1 av 1

Hjälp med rörelsevakt =)

Postat: 03 jan 2015, 19:41
av Kajsas
Tjo

Jag ha hittat denna scen som jag vill ska funka med ett vägguttag , när garage dörren öppnas och rörelsen blir aktiv skall lampan tändas och släckas efter en viss tid.

--[[
%% properties
28 value
%% globals
--]]

--167 = PIR for movement detection

--Scene purpose
--IF PIR detects movement then turn on dimmer and turn it off 5 minutes.
-- If new movement detected during the 5 minute period set the timer for 5 minutes

local sceneId = 62 --ID of this scene, used to detect number of instances run
local timerEndTime = 2 --Minutes to keep the lamp turned on after PIR detects movement
local timer = "timer" --Name of global variabel to control the timer
local timerValue = fibaro:getGlobalValue(timer) --Current value of global variabel for timer
local triggerValue = fibaro:getValue(28, "value") --Get PIR value that activated this scene

local lights = 27 --light to be controlled by this scene

fibaro:debug("start, timer = " .. timerValue .. " lights = " .. fibaro:getValue(lights, "value") .. " ,triggerValue = " .. triggerValue)
if (fibaro:getValue(lights, "value") == "0" and triggerValue == "255") then
--If starts if lights off and PIR detected movement
fibaro:call(lights, "setValue", tostring(dimmerValue)) --Turn lights on
fibaro:setGlobal(timer, timerEndTime) --Set global variabel for timer
while (fibaro:getGlobalValue(timer) ~= "0") do
--Loop used to control timer, each loop 1 minute and continues
--as long as timer variabel isn't 0
timerValue = tonumber(fibaro:getGlobalValue(timer)) --Get current value of global variabel timer
fibaro:setGlobal(timer, timerValue-1) --Decrease global variabel for timer with 1 minute
fibaro:debug("Loop - timer = " .. fibaro:getGlobalValue(timer))
fibaro:sleep(60*1000) --Wait 1 minute
end
fibaro:call(lights, "turnOff") --Turn lights off
elseif fibaro:countScenes(sceneId) > 1 then
--if scene is already running the set timer to 2 minutes
fibaro:setGlobal(timer, timerEndTime) --set global variabel for timer to 2 minutes
fibaro:debug("New instance, totalt = " .. fibaro:countScenes(sceneId))
end
fibaro:debug("End, instances = " .. fibaro:countScenes(sceneId))


Men den gör inte som jag vill , om jag kör scenen får jag följande.

[DEBUG] 18:41:17: start, timer = lights = 0 ,triggerValue = 255
[ERROR] 18:41:17: line 30: attempt to perform arithmetic on local 'timerValue' (a nil value)

Re: Hjälp med rörelsevakt =)

Postat: 03 jan 2015, 21:45
av HenrikEL
Detta är en onödigt stor kod för det du vill ha. Kolla zwave forum och under scener och där finns en för badrum du kan använda. Tiden ställer du sen i din rörelsevakt på parameter 6. Tänk på att väcka enheten med 3 klick så den får infon

Re: Hjälp med rörelsevakt =)

Postat: 03 jan 2015, 21:52
av Kajsas
Ok ok tack Henrik som alltid :)