Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team
Question
zibko1 0
Witam wszystkich adaptowałem z forum poniższą scenę działa dobrze jednak chciałbym jak włączę światło wyłącznikiem to mi nie zgaśnie po 60s
--[[
%% properties
423 value
19 value
%% globals
--]]
-----------------------------------------------------------------------------
fibaro:debug("SCENE START --------------------------")
fibaro:debug("sceneInstance: "..fibaro:countScenes())
if fibaro:countScenes() > 1
then
fibaro:debug("SCENE ABORT --------------------------")
fibaro:abort()
end
-----------------------------------------------------------------------------
-- sensor ruchu
local sensorID = 19
-- światło sufit
local lightID = 423
local delay = 60
local lumen = 200
local timeStart = '19:59'
local timeStop = '06:00'
-- Functions ---------------------------------------------------------------
-- funkcja zamienia czas w formacie tekstowym "HH:MM" lub os.date("*t") na liczbę minut od północy
function toMinutes(czasHHMM)
local a
if type(czasHHMM) == "string"
then
a = tonumber(string.sub(czasHHMM, 1, 2)) * 60 + tonumber(string.sub(czasHHMM, 4, 5))
else
a = tonumber(czasHHMM.hour) * 60 + tonumber(czasHHMM.min)
end
return a
end
------------------------------------------------------------------------------
local minStart = toMinutes(timeStart)
local minStop = toMinutes(timeStop)
local minNow = toMinutes(os.date("*t"))
local sensorMoved = (tonumber(fibaro:getValue(sensorID, "value")) > 0)
local isLightOn = (tonumber(fibaro:getValue(lightID, "value")) > 0)
fibaro:debug("isLightOn: "..tostring(isLightOn))
fibaro:debug("sensorMoved: "..tostring(sensorMoved))
------------------------------------------------------------------------------
local isTime
if (minStop >= minStart)
then
if (minNow >= minStart) and (minNow <= minStop)
then
isTime = true
else
isTime = false
end
elseif (minStop <= minStart)
then
if (minNow <= minStart) and (minNow >= minStop)
then
isTime = false
else
isTime = true
end
end
fibaro:debug("isTime: "..tostring(isTime))
-- zapalanie światła --------------------------------------------------------
if sensorMoved and isTime
then
fibaro:call(lightID, "turnOn")
fibaro:debug("Action: turnOn")
end
if sensorMoved and (not isTime)
then
fibaro:call(lightID, "turnOn")
fibaro:debug("Action: turnOn")
end
-- gaszenie światła ---------------------------------------------------------
if isLightOn
then
local turnOffTime = os.time() + delay
while turnOffTime > os.time()
do
if tonumber(fibaro:getValue(sensorID, "value")) > 0
then
turnOffTime = os.time() + delay
end
fibaro:debug("DELAY: "..tostring(turnOffTime - os.time()))
fibaro:sleep(1000)
-- sprawdzenie czy światło wyłączone ręcznie podczas trwania zwłoki
local isLightOnInLoop = (tonumber(fibaro:getValue(lightID, "value")) + tonumber(fibaro:getValue(lightID, "value")) > 0)
if not isLightOnInLoop
then
fibaro:debug("SCENE ABORT --------- LIGHT TURNED OFF MANUALLY ---------")
fibaro:abort()
end
end
fibaro:call(lightID, "turnOff")
fibaro:debug("Action: turnOff")
end
Top Posters For This Question
24
18
9
9
Popular Days
Jan 27
13
Nov 23
7
Nov 24
7
Jan 11
6
Top Posters For This Question
hoomee 24 posts
10der 18 posts
Thomson 9 posts
eustachy 9 posts
Popular Days
Jan 27 2017
13 posts
Nov 23 2019
7 posts
Nov 24 2019
7 posts
Jan 11 2017
6 posts
Popular Posts
hoomee
No tak, racja. Zapalenie światła pod wpływem ruchu wywołuje scenę ustawienia zmiennej globalnej... ale warto było spróbować Przepisałem całość od nowa używając tylko Twojego mechanizmu s
hoomee
Jeśli to jest dimmer to dodaj na początku odpowiednie linie, żeby wyglądało tak (oczywiście możesz edytować początek wg potrzeb): Please login or register to see this code. a w środku w scenie za
hoomee
Jeśli 423 to jest ID włącznika światła na suficie a nie chcesz, żeby pstryknięcie włącznika uruchamiało scenę, to po prostu usuń 3 linijkę sceny: Please login or register to see this code. Przy t
Posted Images
100 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.