Hej,
jag har en gammal scen som funkar bra som jag nu vill ha på en annan sensor.
Jag vill även lägga till en Fibarod immer i scenen men får inte till det.
nedan är den ursprungliga scenen, och i den vill jag ha en dimmer till
--[[
%% properties
618 value
%% events
%% globals
--]]
if dofile and not _EMULATED then _EMBEDDED={name="TTT",id=20} dofile("HC2.lua") end
local sensor = 618
local lamp = 581
local countDown = 1*10 -- turn off lamp after sensor safe for 5min
function printf(...) fibaro:debug(string.format(...)) end
if fibaro:countScenes() > 1 then fibaro:abort() end -- only run one instance
local time = os.date("%H:%M")
-- Right time? else exit
if not (time >= "22:00" or time <= "07:00") then fibaro:abort() end
local trigger = fibaro:getSourceTrigger()
if trigger.type=='property' then -- only one trigger so it must be our sensor
local flag = true
if fibaro:getValue(sensor,"value") > "0" then -- if breached
printf("Sensor %s breached, turning on lamp %s",sensor,lamp)
fibaro:call(lamp,"setValue",20) -- turn on lamp
local seconds = countDown -- initialise count down to seconds we will wait
repeat
if fibaro:getValue(sensor,"value") == "0" then -- if sensor safe, count down seconds
if flag then printf("Sensor %s safe, counting down",sensor); flag = false end
seconds = seconds-1
else
printf("Sensor %s breached, resetting counter to %ss",sensor,countDown); flag = true
seconds = countDown -- else reset count down
end
fibaro:sleep(1000) -- sleep 1 second
until seconds <= 0 -- until safe for time specified
printf("Sensor safe for %ss, turning off lamp %s",sensor,lamp)
fibaro:call(lamp,"turnOff") -- ...then turn off lamp
end
end
Motion Sensor
- RH_Dreambox
- Z-Wave Kung
- Posts: 1117
- Joined: 03 Jan 2015, 16:49
- 6
- Location: Vegby
- Contact:
Enklast är väl att göra så här...
Ändra lamp till lamp1 och lägg till lamp2
local sensor = 618
local lamp1 = 581
local lamp2 = ???
Lägg till en rad för att tända lamp1 och lamp2
fibaro:call(lamp1,"setValue",20) -- turn on lamp1
fibaro:call(lamp2,"setValue",20) -- turn on lamp2
Längst ned lägger du till en rad för att släcka lamp1 och lamp2
fibaro:call(lamp1,"turnOff") -- ...then turn off lamp1
fibaro:call(lamp2,"turnOff") -- ...then turn off lamp2
Och raden längst upp
if dofile and not _EMULATED then _EMBEDDED={name="TTT",id=20} dofile("HC2.lua") end
Den kan du ta bort för den använder du väl dig inte av?
Ändra lamp till lamp1 och lägg till lamp2
local sensor = 618
local lamp1 = 581
local lamp2 = ???
Lägg till en rad för att tända lamp1 och lamp2
fibaro:call(lamp1,"setValue",20) -- turn on lamp1
fibaro:call(lamp2,"setValue",20) -- turn on lamp2
Längst ned lägger du till en rad för att släcka lamp1 och lamp2
fibaro:call(lamp1,"turnOff") -- ...then turn off lamp1
fibaro:call(lamp2,"turnOff") -- ...then turn off lamp2
Och raden längst upp
if dofile and not _EMULATED then _EMBEDDED={name="TTT",id=20} dofile("HC2.lua") end
Den kan du ta bort för den använder du väl dig inte av?
HC3 (5.062 Beta) med ER4 och HC2 (4.600) med ER 3
Låt säga att båda armaturerna ska släckas efter 5 minuter på dagen.
Men bara en armatur ska tändas mellan 23:59 & 07:00
Hur skulle då scenen se ut ?
--[[
%% properties
618 value
%% events
%% globals
--]]
local sensor = 618
local lamp1 = 581
local lamp2 = 91
local countDown = 1*60 -- turn off lamp after sensor safe for 5min
function printf(...) fibaro:debug(string.format(...)) end
if fibaro:countScenes() > 1 then fibaro:abort() end -- only run one instance
local time = os.date("%H:%M")
-- Right time? else exit
if not (time >= "23:59" or time <= "07:00") then fibaro:abort() end
local trigger = fibaro:getSourceTrigger()
if trigger.type=='property' then -- only one trigger so it must be our sensor
local flag = true
if fibaro:getValue(sensor,"value") > "0" then -- if breached
printf("Sensor %s breached, turning on lamp %s",sensor,lamp)
fibaro:call(lamp1,"setValue",20) -- turn on lamp1
fibaro:call(lamp2,"setValue",3) -- turn on lamp2) -- turn on lamp
local seconds = countDown -- initialise count down to seconds we will wait
repeat
if fibaro:getValue(sensor,"value") == "0" then -- if sensor safe, count down seconds
if flag then printf("Sensor %s safe, counting down",sensor); flag = false end
seconds = seconds-1
else
printf("Sensor %s breached, resetting counter to %ss",sensor,countDown); flag = true
seconds = countDown -- else reset count down
end
fibaro:sleep(1000) -- sleep 1 second
until seconds <= 0 -- until safe for time specified
printf("Sensor safe for %ss, turning off lamp %s",sensor,lamp)
fibaro:call(lamp1,"turnOff") -- ...then turn off lamp1
fibaro:call(lamp2,"turnOff") -- ...then turn off lamp2 -- ...then turn off lamp
end
end
Men bara en armatur ska tändas mellan 23:59 & 07:00
Hur skulle då scenen se ut ?
--[[
%% properties
618 value
%% events
%% globals
--]]
local sensor = 618
local lamp1 = 581
local lamp2 = 91
local countDown = 1*60 -- turn off lamp after sensor safe for 5min
function printf(...) fibaro:debug(string.format(...)) end
if fibaro:countScenes() > 1 then fibaro:abort() end -- only run one instance
local time = os.date("%H:%M")
-- Right time? else exit
if not (time >= "23:59" or time <= "07:00") then fibaro:abort() end
local trigger = fibaro:getSourceTrigger()
if trigger.type=='property' then -- only one trigger so it must be our sensor
local flag = true
if fibaro:getValue(sensor,"value") > "0" then -- if breached
printf("Sensor %s breached, turning on lamp %s",sensor,lamp)
fibaro:call(lamp1,"setValue",20) -- turn on lamp1
fibaro:call(lamp2,"setValue",3) -- turn on lamp2) -- turn on lamp
local seconds = countDown -- initialise count down to seconds we will wait
repeat
if fibaro:getValue(sensor,"value") == "0" then -- if sensor safe, count down seconds
if flag then printf("Sensor %s safe, counting down",sensor); flag = false end
seconds = seconds-1
else
printf("Sensor %s breached, resetting counter to %ss",sensor,countDown); flag = true
seconds = countDown -- else reset count down
end
fibaro:sleep(1000) -- sleep 1 second
until seconds <= 0 -- until safe for time specified
printf("Sensor safe for %ss, turning off lamp %s",sensor,lamp)
fibaro:call(lamp1,"turnOff") -- ...then turn off lamp1
fibaro:call(lamp2,"turnOff") -- ...then turn off lamp2 -- ...then turn off lamp
end
end
Homecenter 2
Kameror, värme, larm och belysning från olika leverantörer
Kameror, värme, larm och belysning från olika leverantörer