Jump to content

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


  • 0

Scena światło - właczenie i wyłączenie po 60s


zibko1

Question

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

Link to comment
Share on other sites

Recommended Posts

  • 0

Witam

 

Przestudiowałem ten post i scena działa bardzo fajnie na dimmerach.

Lamerskie pytanie brzmi co trzeba by było zmienić żeby dopasować ją do switcha (oczywiście nie chodzi o natężenie światła a tylko rozróżnienie czasu gaszenia zależnie od sposobu uruchomienia czujka/ręcznie)

Z góry dziękuję

Link to comment
Share on other sites

  • 0

Jeśli masz zwykłe switche zamiast dimmerów, to najprościej jest zastąpić linijki

 

        fibaro:call(lightID, "setValue", lightDay)

i

        fibaro:call(lightID, "setValue", lightNight)

 

które są odpowiedzialne za zapalenie światła o określonym natężeniu, jedną linijką (w obu miejscach, jeśli chcesz by działało w dzień i w nocy, albo w jednym wedlug potrzeb)

 

        fibaro:call(lightID, "turnOn")

 

która po prostu włączy światło. Możesz wtedy również usunąć (albo wykomentować, czyli dodać "--" na początku) dwie zmienne na początku sceny:

 

-- local lightDay = 100                -- moc światła w dzień
-- local lightNight = 100              -- moc światła w nocy

 

Pozdrawiam

Link to comment
Share on other sites

  • 0

Bardzo dziękuję. Działa jak trzeba.

Tak myślałem, że to kwestia różnych komend albo nazw...

Obiecuję następnym razem bardziej postarać się samemu.

Dopiero mam zamiar zacząć zabawę z LUA a akurat jestem u kolegi i chciałem mu na szybko pomóc opanować w sumie podstawową funkcjonalność fibaro.

 

Link to comment
Share on other sites

  • 0

Witam.

Mam pytanie co trzeba by było zrobi aby  oświetlenie włączało i wyłączało się po np. 60s  s automatycznie z czujki ruchu, jednej lub kilku ale  od zmierzchu do świtu np. wykorzystując scenę isNight oraz sterując ręcznie oświetleniem przez cały dzień, mając zainstalowane switche, oraz to samo wykorzystując sterownik iLED  RGB .

Z góry dziękuję.

pozdrawiam

Link to comment
Share on other sites

  • 0

Ta scena zasadniczo powstała niejako przez przypadek, bo chodziło o proste rozwiązanie do prostych założeń, i rozrosła się w miarę wzrostu zainteresowania ;)

Ja u siebie jej używam w prostej wersji: jedna czujka, jeden zciemniacz, działanie tylko w nocy. Jeśli chodzi o bardziej zaawansowane rozwiązania (wiele czujek, wiele aktorów, różne czasy reakcji) to polecam raczej dostępną na forum anglojęzycznym scenę inteligentnych świateł (Very Smart Lights), która wg opisu może sterować grupą świateł (nigdy jej osobiście nie testowałem). Jeśli zachodziłaby potrzeba użycia sceny dodatkowej czy innych dodatkowych zmiennych to polecam stanowczo Very Smart Lights - prawdopodobnie sprawdzi się lepiej.

 

On 19/4/2017 at 0:17 PM, ptactwo said:

(...) wyłączało się po np. 60s  s automatycznie z czujki ruchu, jednej lub kilku ale  od zmierzchu do świtu np. wykorzystując scenę isNight oraz sterując ręcznie oświetleniem przez cały dzień, mając zainstalowane switche, oraz to samo wykorzystując sterownik iLED  RGB

 

1 - użycie tylko w nocy: wystarczy "wykomentować" (czyli dodać dwie kreski "--" na początku linijki) następującą linijkę (gdzieś mniej więcej w środku sceny):

Please login or register to see this code.

2 - użycie kilku czujek jest dość skomplikowane, bo 1) każde sprawdzenie czy scena jest wywołana ruchem wymagałaby dodatkowej bramki, a 2) zmienna lokalna "sensorMoved" musiałaby być ustawiana przez dodatkowy mechanizm przy naruszeniu jednej z czujek. Polecam sprawdzić scenę, o której wspomniałem wyżej.

 

3 - sterowanie ręczne w zasadzie nie potrzebuje żadnych implementacji, bo działa zawsze (dzień i noc)

 

4 - jeśli chodzi o switche zamiast dimmerów, to tak jak w moim ostatnim poście - zamiana odpowiednich linijek to zrobi.

 

5 - nie mam sterownika RGB, więc nie mogę sam sprawdzić, ale odpowiednia komenda jak w punkcie 4 powinna zadziałać.

 

Link to comment
Share on other sites

  • 0

Witam

Dziękuję za szybką odpowiedź.

 W mojej scenie nie mam takiego wpisu jak podałeś aby scena uruchamiała się tylko w nocy.

 

 

----------------

 

--[[
%% properties 
50 value
854 value
%% globals 
--]] 

local sensorID = 50                 -- sensor ruchu
local lightID = 854                  -- światło sufit
local delay = 20                    -- opóźnienie gaszenia w sekundach 
local nightStartsat = 12            -- początek ciszy nocnej
local dayStartsat = 7               -- koniec ciszy nocnej
local lightDay = 100                -- moc światła w dzień
local lightNight = 100              -- moc światła w nocy
---- nie edytuj poniżej tej linii -------------------------------------------
local startSource = fibaro:getSourceTrigger()
-----------------------------------------------------------------------------
-- reakcja na ruch
-- czy nie za dużo instancji
if ( (startSource.deviceID == sensorID) and (fibaro:countScenes() > 1) )
  then
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("za dużo scen: "..fibaro:countScenes())
    fibaro:debug("źródło: "..startSource.deviceID)
    fibaro:debug(fibaro:getGlobal("manualOn"))
    fibaro:debug("scena numer: "..fibaro:countScenes())
    fibaro:debug("--------- aborting ----------") 
    fibaro:abort() 
-- czy globalna zmienna mówi, że światło włączone ręcznie 
elseif ( (startSource.deviceID == sensorID) and (tostring(fibaro:getGlobal("manualOn")) == "true") )
  then
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("światło było zapalone ręcznie")
    fibaro:debug("źródło: "..startSource.deviceID)
    fibaro:debug(fibaro:getGlobal("manualOn"))
    fibaro:debug("scena numer: "..fibaro:countScenes())
    fibaro:debug("--------- aborting ----------") 
    fibaro:abort() 
elseif( (startSource.deviceID == sensorID) and (tostring(fibaro:getGlobal("manualOn")) == "false") )
  then
  local sensorMoved = (tonumber(fibaro:getValue(sensorID, "value")) > 0)
  local isLightOn = (tonumber(fibaro:getValue(lightID, "value")) > 0)
  fibaro:debug("--------- debugging ----------")
  fibaro:debug("źródło: "..startSource.deviceID)
  fibaro:debug("scena numer: "..fibaro:countScenes())
  fibaro:debug("isLightOn: "..tostring(isLightOn))
  fibaro:debug("sensorMoved: "..tostring(sensorMoved))
-- zapalanie światła
  if sensorMoved 
    then 
    if ( (tonumber(os.date("%H")) >= nightStartsat) or (tonumber(os.date("%H")) < dayStartsat) )
      then
        fibaro:call(lightID, "turnOn")
        fibaro:debug("Jest noc, natężenie światła: "..lightNight)
        fibaro:sleep(1000)
        fibaro:debug("koniec sceny")
    elseif ( (tonumber(os.date("%H")) >= dayStartsat) and (tonumber(os.date("%H")) < nightStartsat) )
      then
        fibaro:call(lightID, "turnOn")
        fibaro:debug("Jest dzień, natężenie światła: "..lightDay)
        fibaro:sleep(1000)
        fibaro:debug("koniec sceny")
    else
      fibaro:debug(os.date("%H"))
      fibaro:debug("dziwny błąd, aborting")
      fibaro:abort() 
    end
  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)
      end
-- sprawdzenie czy światło wyłączone ręcznie podczas trwania zwłoki (zmienna globalna) 
    if (tostring(fibaro:getGlobal("manualOn")) == "true")
      then 
      fibaro:debug("--------- debugging ----------")
      fibaro:debug("SCENE ABORT -----------MANUAL ON ACTIVATED---------------") 
      fibaro:abort() 
    end
    fibaro:call(lightID, "turnOff")
    fibaro:debug("Action: turnOff") 
  end 
elseif ( startSource.deviceID == lightID ) 
  then
  fibaro:debug("--------- debugging ----------") 
  fibaro:debug("wywołanie światłem")
  fibaro:debug("źródło: "..startSource.deviceID)
  fibaro:debug("scena numer: "..fibaro:countScenes())
--  fibaro:sleep(1000)
  local sensorMoved = (tonumber(fibaro:getValue(sensorID, "value")) > 0)
  if ( (fibaro:countScenes() == 1) or (not sensorMoved) )
    then
    if (tonumber(fibaro:getValue(lightID, "value")) > 0)
      then
      fibaro:debug("--------- debugging ----------") 
      fibaro:debug("zapalenie ręczne")
      fibaro:debug("źródło: "..startSource.deviceID)
      fibaro:debug("scena numer: "..fibaro:countScenes())
      fibaro:setGlobal("manualOn", "true")
      fibaro:abort()
    elseif (tonumber(fibaro:getValue(lightID, "value")) == 0)
    then
      fibaro:debug("--------- debugging ----------") 
      fibaro:debug("zgaszenie")
      fibaro:debug("źródło: "..startSource.deviceID)
      fibaro:debug("scena numer: "..fibaro:countScenes())
      fibaro:setGlobal("manualOn", "false")
      fibaro:abort()
    end
  end
elseif ( (tostring(fibaro:getGlobal("manualOn")) ~= "true") and 
         (tostring(fibaro:getGlobal("manualOn")) ~= "false") )
  then
      fibaro:debug("--------- debugging ----------") 
      fibaro:debug("źródło: "..startSource.deviceID)
      fibaro:debug("scena numer: "..fibaro:countScenes())
      fibaro:debug("problem ze zmienną globalną")
      fibaro:debug("nie jest ani true ani false")
      fibaro:abort()
elseif startSource["type"] == "other"
  then
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("Scena wywołana ręcznie")
    fibaro:debug("Zapal światło lub aktywuj czujnik ruchu")
    fibaro:debug("koniec sceny")
else
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("źródło: "..startSource.deviceID)
    fibaro:debug("scena numer: "..fibaro:countScenes())
    fibaro:debug("unexpected error! aborting")
    fibaro:debug("--------- aborting ----------")
    fibaro:abort()
end

 

 

------------------

 

 a to druga scena z RGB i też nie ma takiego opisu

 

--[[
%% properties 
503 value
843 value
%% globals 
--]] 

local sensorID = 503                -- sensor ruchu
local lightID = 843                -- światło sufit
local delay = 60                    -- opóźnienie gaszenia w sekundach 

---- nie edytuj poniżej tej linii -------------------------------------------
local startSource = fibaro:getSourceTrigger()
-----------------------------------------------------------------------------
-- reakcja na ruch
-- czy nie za dużo instancji
if ( (startSource.deviceID == sensorID) and (fibaro:countScenes() > 1) )
  then
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("za dużo scen: "..fibaro:countScenes())
    fibaro:debug("źródło: "..startSource.deviceID)
    fibaro:debug(fibaro:getGlobal("manualOn"))
    fibaro:debug("scena numer: "..fibaro:countScenes())
    fibaro:debug("--------- aborting ----------") 
    fibaro:abort() 
-- czy globalna zmienna mówi, że światło włączone ręcznie 
elseif ( (startSource.deviceID == sensorID) and (tostring(fibaro:getGlobal("manualOn")) == "true") )
  then
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("światło było zapalone ręcznie")
    fibaro:debug("źródło: "..startSource.deviceID)
    fibaro:debug(fibaro:getGlobal("manualOn"))
    fibaro:debug("scena numer: "..fibaro:countScenes())
    fibaro:debug("--------- aborting ----------") 
    fibaro:abort() 
elseif( (startSource.deviceID == sensorID) and (tostring(fibaro:getGlobal("manualOn")) == "false") )
  then
  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))
-- zapalanie światła
  if sensorMoved 
    then 
      fibaro:call(lightID, "turnOn")
      fibaro:debug("Action: turnOn")
      fibaro:sleep(1000)
  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)
      end
-- sprawdzenie czy światło wyłączone ręcznie podczas trwania zwłoki (zmienna globalna) 
    if (tostring(fibaro:getGlobal("manualOn")) == "true")
      then 
      fibaro:debug("SCENE ABORT -----------MANUAL ON ACTIVATED---------------") 
      fibaro:abort() 
    end
    fibaro:call(lightID, "turnOff")
    fibaro:debug("Action: turnOff") 
  end 
elseif ( startSource.deviceID == lightID ) 
  then
  local sensorMoved = (tonumber(fibaro:getValue(sensorID, "value")) > 0)
  if ( (fibaro:countScenes() == 1) or (not sensorMoved) )
    then
    if (tonumber(fibaro:getValue(lightID, "value")) > 0)
      then
      fibaro:debug("--------- debugging ----------") 
      fibaro:debug("zapalenie ręczne")
      fibaro:debug("źródło: "..startSource.deviceID)
      fibaro:debug("scena numer: "..fibaro:countScenes())
      fibaro:setGlobal("manualOn", "true")
      fibaro:abort()
    elseif (tonumber(fibaro:getValue(lightID, "value")) == 0)
    then
      fibaro:debug("--------- debugging ----------") 
      fibaro:debug("zgaszenie")
      fibaro:debug("źródło: "..startSource.deviceID)
      fibaro:debug("scena numer: "..fibaro:countScenes())
      fibaro:setGlobal("manualOn", "false")
      fibaro:abort()
    end
  end
else
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("źródło: "..startSource.deviceID)
    fibaro:debug("scena numer: "..fibaro:countScenes())
    fibaro:debug("unexpected error! aborting")
    fibaro:debug("--------- aborting ----------")
    fibaro:abort()
end

 

---------------------

Obie sceny działają poprawnie ale załączają się w czasie dnia i to właśnie chciałbym wyeliminować.

 

Piszesz że używasz prostych scen jedna czujka i ściemniacz czy w tej scenie można użyć kilka czujek jeden ściemniacz lub switch.

Czy mógłbyś zerknąć na te sceny i je poprawić.

pozdrawiam i z góry dziękuję

 

Edited by ptactwo
Link to comment
Share on other sites

  • 0
1 hour ago, ptactwo said:

czy w tej scenie można użyć kilka czujek jeden ściemniacz lub switch.

 

Można użyć kilka dimmerów lub switchy, ale ciężko jest użyć kilku detektorów ruchu.

Tak jak napisałem powyżej:

 

4 hours ago, hoomee said:

2 - użycie kilku czujek jest dość skomplikowane, bo 1) każde sprawdzenie czy scena jest wywołana ruchem wymagałaby dodatkowej bramki, a 2) zmienna lokalna "sensorMoved" musiałaby być ustawiana przez dodatkowy mechanizm przy naruszeniu jednej z czujek. Polecam sprawdzić scenę, o której wspomniałem wyżej.

 

Masz dwie różne wersje sceny. Pierwsza rozpoznaje noc i dzień i działa na switchu, więc rzeczywiście nie ma tam linijki, o której pisałem. Musisz wykomentować linijkę, którą zaznaczyłem na czerwono. Scena będzie się uruchamiała, ale tylko napisze, że jest dzień i nie zapali światła.

 

1 hour ago, ptactwo said:

-- zapalanie światła
  if sensorMoved 
    then 
    if ( (tonumber(os.date("%H")) >= nightStartsat) or (tonumber(os.date("%H")) < dayStartsat) )
      then
        fibaro:call(lightID, "turnOn")
        fibaro:debug("Jest noc, natężenie światła: "..lightNight)
        fibaro:sleep(1000)
        fibaro:debug("koniec sceny")
    elseif ( (tonumber(os.date("%H")) >= dayStartsat) and (tonumber(os.date("%H")) < nightStartsat) )
      then
        fibaro:call(lightID, "turnOn")
        fibaro:debug("Jest dzień, natężenie światła: "..lightDay)
        fibaro:sleep(1000)
        fibaro:debug("koniec sceny")
    else
      fibaro:debug(os.date("%H"))
      fibaro:debug("dziwny błąd, aborting")
      fibaro:abort() 
    end
  end
-- gaszenie światła 

 

Druga scena (ta z RGB) nie rozpoznaje dnia i nocy, więc żeby działało tylko w nocy musisz ją przepisać wg swojej pierwszej sceny i tylko zmienić ID urządzeń i również wykomentować czerwoną linijkę.

 

Pamiętaj również, żeby w nightStartsat wpisać godzinę w formacie 24h. W tej chwili noc zaczyna się w południe:

1 hour ago, ptactwo said:

local delay = 20                    -- opóźnienie gaszenia w sekundach 
local nightStartsat = 12            -- początek ciszy nocnej
local dayStartsat = 7               -- koniec ciszy nocnej
local lightDay = 100                -- moc światła w dzień

 

Link to comment
Share on other sites

  • 0

Jeżeli jest to możliwe poproszę jeszcze zależność. 

bym poprosił o dopisanie aby scena włączała się poniżej lub równe 2 lux-ów

 

 

Ta scena bardzo pięknie działa jak jest ciemno czyli 0 lux-ów

 

 

 

--[[
%% properties 
429 value
425 value
%% globals 
--]] 
local sensorID = 429                 -- sensor ruchu
local lightID = 425                  -- światło sufit
local delay = 60                    -- opóźnienie gaszenia w sekundach 
local nightStartsat = 10            -- początek ciszy nocnej
local dayStartsat = 6               -- koniec ciszy nocnej
local lightDay = 100               -- moc światła w dzień
local lightNight = 100              -- moc światła w nocy
---- nie edytuj poniżej tej linii -------------------------------------------
local startSource = fibaro:getSourceTrigger()
-----------------------------------------------------------------------------
-- reakcja na ruch
-- czy nie za dużo instancji
if ( (startSource.deviceID == sensorID) and (fibaro:countScenes() > 1) )
  then
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("za dużo scen: "..fibaro:countScenes())
    fibaro:debug("źródło: "..startSource.deviceID)
    fibaro:debug(fibaro:getGlobal("manualOn"))
    fibaro:debug("scena numer: "..fibaro:countScenes())
    fibaro:debug("--------- aborting ----------") 
    fibaro:abort() 
-- czy globalna zmienna mówi, że światło włączone ręcznie 
elseif ( (startSource.deviceID == sensorID) and (tostring(fibaro:getGlobal("manualOn")) == "true") )
  then
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("światło było zapalone ręcznie")
    fibaro:debug("źródło: "..startSource.deviceID)
    fibaro:debug(fibaro:getGlobal("manualOn"))
    fibaro:debug("scena numer: "..fibaro:countScenes())
    fibaro:debug("--------- aborting ----------") 
    fibaro:abort() 
elseif( (startSource.deviceID == sensorID) and (tostring(fibaro:getGlobal("manualOn")) == "false") )
  then
  local sensorMoved = (tonumber(fibaro:getValue(sensorID, "value")) > 0)
  local isLightOn = (tonumber(fibaro:getValue(lightID, "value")) > 0)
  fibaro:debug("--------- debugging ----------")
  fibaro:debug("źródło: "..startSource.deviceID)
  fibaro:debug("scena numer: "..fibaro:countScenes())
  fibaro:debug("isLightOn: "..tostring(isLightOn))
  fibaro:debug("sensorMoved: "..tostring(sensorMoved))
-- zapalanie światła
  if sensorMoved 
    then 
    if ( (tonumber(os.date("%H")) >= nightStartsat) or (tonumber(os.date("%H")) < dayStartsat) )
      then
        fibaro:call(lightID, "turnOn")
        fibaro:debug("Jest noc, natężenie światła: "..lightNight)
        fibaro:sleep(1000)
        fibaro:debug("koniec sceny")
    elseif ( (tonumber(os.date("%H")) >= dayStartsat) and (tonumber(os.date("%H")) < nightStartsat) )
      then
        fibaro:call(lightID, "turnOn")
        fibaro:debug("Jest dzień, natężenie światła: "..lightDay)
        fibaro:sleep(1000)
        fibaro:debug("koniec sceny")
    else
      fibaro:debug(os.date("%H"))
      fibaro:debug("dziwny błąd, aborting")
      fibaro:abort() 
    end
  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)
      end
-- sprawdzenie czy światło wyłączone ręcznie podczas trwania zwłoki (zmienna globalna) 
    if (tostring(fibaro:getGlobal("manualOn")) == "true")
      then 
      fibaro:debug("--------- debugging ----------")
      fibaro:debug("SCENE ABORT -----------MANUAL ON ACTIVATED---------------") 
      fibaro:abort() 
    end
    fibaro:call(lightID, "turnOff")
    fibaro:debug("Action: turnOff") 
  end 
elseif ( startSource.deviceID == lightID ) 
  then
  fibaro:debug("--------- debugging ----------") 
  fibaro:debug("wywołanie światłem")
  fibaro:debug("źródło: "..startSource.deviceID)
  fibaro:debug("scena numer: "..fibaro:countScenes())
--  fibaro:sleep(1000)
  local sensorMoved = (tonumber(fibaro:getValue(sensorID, "value")) > 0)
  if ( (fibaro:countScenes() == 1) or (not sensorMoved) )
    then
    if (tonumber(fibaro:getValue(lightID, "value")) > 0)
      then
      fibaro:debug("--------- debugging ----------") 
      fibaro:debug("zapalenie ręczne")
      fibaro:debug("źródło: "..startSource.deviceID)
      fibaro:debug("scena numer: "..fibaro:countScenes())
      fibaro:setGlobal("manualOn", "true")
      fibaro:abort()
    elseif (tonumber(fibaro:getValue(lightID, "value")) == 0)
    then
      fibaro:debug("--------- debugging ----------") 
      fibaro:debug("zgaszenie")
      fibaro:debug("źródło: "..startSource.deviceID)
      fibaro:debug("scena numer: "..fibaro:countScenes())
      fibaro:setGlobal("manualOn", "false")
      fibaro:abort()
    end
  end
elseif ( (tostring(fibaro:getGlobal("manualOn")) ~= "true") and 
         (tostring(fibaro:getGlobal("manualOn")) ~= "false") )
  then
      fibaro:debug("--------- debugging ----------") 
      fibaro:debug("źródło: "..startSource.deviceID)
      fibaro:debug("scena numer: "..fibaro:countScenes())
      fibaro:debug("problem ze zmienną globalną")
      fibaro:debug("nie jest ani true ani false")
      fibaro:abort()
elseif startSource["type"] == "other"
  then
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("Scena wywołana ręcznie")
    fibaro:debug("Zapal światło lub aktywuj czujnik ruchu")
    fibaro:debug("koniec sceny")
else
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("źródło: "..startSource.deviceID)
    fibaro:debug("scena numer: "..fibaro:countScenes())
    fibaro:debug("unexpected error! aborting")
    fibaro:debug("--------- aborting ----------")
    fibaro:abort()
end
 

Edited by elektron
Link to comment
Share on other sites

  • 0

The topic has been moved from "

Please login or register to see this link.

" to "

Please login or register to see this link.

".

 

Temat został przeniesiony z "

Please login or register to see this link.

" do "

Please login or register to see this link.

".

Link to comment
Share on other sites

  • 0
On 29.07.2017 at 6:04 PM, elektron said:

Jeżeli jest to możliwe poproszę jeszcze zależność. 

bym poprosił o dopisanie aby scena włączała się poniżej lub równe 2 lux-ów

 

 

Zapytałeś dokładnie przed urlopem ;)

Pisałem już

Please login or register to see this link.

2 lux wydaje mi się dość małą granicą, ale ja mieszkam w okolicy bardzo zanieczyszczonej światłem, a w domu też każde urządzenie ma jak nie diodę to chociaż diódkę (!).

Sprawdź również dobrze czy używasz poprawnego ID czujki światła. Nie będę miał możliwości przetestowania tej sceny.

 

Musisz dodać na początku (nad linijką, poniżej której masz nie edytować):

Please login or register to see this code.

a poniżej w tym miejscu:

Please login or register to see this code.

dodać:

Please login or register to see this code.

 

 

Edited by hoomee
  • Like 1
Link to comment
Share on other sites

  • 0

Dziękuje za skrypt. Wszystko mi działa.

Czy można zmienić znak równości na mniejszości

np.

local backgroundLight = 4

local backgroundLight < 4

 

Edited by elektron
Link to comment
Share on other sites

  • 0
On 6 September 2017 at 8:13 AM, elektron said:

Dziękuje za skrypt. Wszystko mi działa.

Czy można zmienić znak równości na mniejszości

np.

local backgroundLight = 4

local backgroundLight < 4

 

 

Nie można. W tym miejscu zmienna jest deklarowana (tak mówisz skryptowi jak ma rozumieć słowo backgroundLight). Jeśli postawisz znak mniejszości to skrypt się wysypie mówiąc, że spotkał błąd składni.

W bramce "if" jest za to znak mniejszy-równy (<=) który jest oceniany logicznie: jeśli wartość czujki jest <= 4 to...

Link to comment
Share on other sites

  • 0

Proszę o pomoc jak dołączyć drugi sensor ruchu 

 

 

 

--[[
%% properties 
429 value
425 value
%% globals 
--]] 
local sensorID = 429                -- sensor ruchu            jak dołączyć drugi sensor ruchu  id 450
local lightID = 425                 -- światło sufit
local lightsensorID = 431           -- czujka jasności
local backgroundLight = 2           -- powyżej jakiej wartości ma nie działać
local delay = 60                    -- opóźnienie gaszenia w sekundach 
local nightStartsat = 10            -- początek ciszy nocnej
local dayStartsat = 6               -- koniec ciszy nocnej
local lightDay = 100               -- moc światła w dzień
local lightNight = 100              -- moc światła w nocy
---- nie edytuj poniżej tej linii -------------------------------------------
local startSource = fibaro:getSourceTrigger()
-----------------------------------------------------------------------------
-- reakcja na ruch
-- czy nie za dużo instancji
if ( (startSource.deviceID == sensorID) and (fibaro:countScenes() > 1) )
  then
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("za dużo scen: "..fibaro:countScenes())
    fibaro:debug("źródło: "..startSource.deviceID)
    fibaro:debug(fibaro:getGlobal("manualOn"))
    fibaro:debug("scena numer: "..fibaro:countScenes())
    fibaro:debug("--------- aborting ----------") 
    fibaro:abort() 
-- czy globalna zmienna mówi, że światło włączone ręcznie 
elseif ( (startSource.deviceID == sensorID) and (tostring(fibaro:getGlobal("manualOn")) == "true") )
  then
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("światło było zapalone ręcznie")
    fibaro:debug("źródło: "..startSource.deviceID)
    fibaro:debug(fibaro:getGlobal("manualOn"))
    fibaro:debug("scena numer: "..fibaro:countScenes())
    fibaro:debug("--------- aborting ----------") 
    fibaro:abort() 
elseif( (startSource.deviceID == sensorID) and (tostring(fibaro:getGlobal("manualOn")) == "false") )
  then
  local sensorMoved = (tonumber(fibaro:getValue(sensorID, "value")) > 0)
  local isLightOn = (tonumber(fibaro:getValue(lightID, "value")) > 0)
  fibaro:debug("--------- debugging ----------")
  fibaro:debug("źródło: "..startSource.deviceID)
  fibaro:debug("scena numer: "..fibaro:countScenes())
  fibaro:debug("isLightOn: "..tostring(isLightOn))
  fibaro:debug("sensorMoved: "..tostring(sensorMoved))
-- zapalanie światła
  if ( sensorMoved and (tonumber(fibaro:getValue(lightsensorID, "value")) <= backgroundLight) )
    then 
    if ( (tonumber(os.date("%H")) >= nightStartsat) or (tonumber(os.date("%H")) < dayStartsat) )
      then
        fibaro:call(lightID, "turnOn")
        fibaro:debug("Jest noc, natężenie światła: "..lightNight)
        fibaro:sleep(1000)
        fibaro:debug("koniec sceny")
    elseif ( (tonumber(os.date("%H")) >= dayStartsat) and (tonumber(os.date("%H")) < nightStartsat) )
      then
        fibaro:call(lightID, "turnOn")
        fibaro:debug("Jest dzień, natężenie światła: "..lightDay)
        fibaro:sleep(1000)
        fibaro:debug("koniec sceny")
    else
      fibaro:debug(os.date("%H"))
      fibaro:debug("dziwny błąd, aborting")
      fibaro:abort() 
    end
  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)
      end
-- sprawdzenie czy światło wyłączone ręcznie podczas trwania zwłoki (zmienna globalna) 
    if (tostring(fibaro:getGlobal("manualOn")) == "true")
      then 
      fibaro:debug("--------- debugging ----------")
      fibaro:debug("SCENE ABORT -----------MANUAL ON ACTIVATED---------------") 
      fibaro:abort() 
    end
    fibaro:call(lightID, "turnOff")
    fibaro:debug("Action: turnOff") 
  end 
elseif ( startSource.deviceID == lightID ) 
  then
  fibaro:debug("--------- debugging ----------") 
  fibaro:debug("wywołanie światłem")
  fibaro:debug("źródło: "..startSource.deviceID)
  fibaro:debug("scena numer: "..fibaro:countScenes())
--  fibaro:sleep(1000)
  local sensorMoved = (tonumber(fibaro:getValue(sensorID, "value")) > 0)
  if ( (fibaro:countScenes() == 1) or (not sensorMoved) )
    then
    if (tonumber(fibaro:getValue(lightID, "value")) > 0)
      then
      fibaro:debug("--------- debugging ----------") 
      fibaro:debug("zapalenie ręczne")
      fibaro:debug("źródło: "..startSource.deviceID)
      fibaro:debug("scena numer: "..fibaro:countScenes())
      fibaro:setGlobal("manualOn", "true")
      fibaro:abort()
    elseif (tonumber(fibaro:getValue(lightID, "value")) == 0)
    then
      fibaro:debug("--------- debugging ----------") 
      fibaro:debug("zgaszenie")
      fibaro:debug("źródło: "..startSource.deviceID)
      fibaro:debug("scena numer: "..fibaro:countScenes())
      fibaro:setGlobal("manualOn", "false")
      fibaro:abort()
    end
  end
elseif ( (tostring(fibaro:getGlobal("manualOn")) ~= "true") and 
         (tostring(fibaro:getGlobal("manualOn")) ~= "false") )
  then
      fibaro:debug("--------- debugging ----------") 
      fibaro:debug("źródło: "..startSource.deviceID)
      fibaro:debug("scena numer: "..fibaro:countScenes())
      fibaro:debug("problem ze zmienną globalną")
      fibaro:debug("nie jest ani true ani false")
      fibaro:abort()
elseif startSource["type"] == "other"
  then
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("Scena wywołana ręcznie")
    fibaro:debug("Zapal światło lub aktywuj czujnik ruchu")
    fibaro:debug("koniec sceny")
else
    fibaro:debug("--------- debugging ----------") 
    fibaro:debug("źródło: "..startSource.deviceID)
    fibaro:debug("scena numer: "..fibaro:countScenes())
    fibaro:debug("unexpected error! aborting")
    fibaro:debug("--------- aborting ----------")
    fibaro:abort()
end

Edited by elektron
Link to comment
Share on other sites

  • 0
12 hours ago, elektron said:

Proszę o pomoc jak dołączyć drugi sensor ruchu 

 

Teoretycznie być może dałoby się tę scenę "wzbogacić" o drugi czujnik ruchu, ale - jako że nie jestem programistą - wymagałoby to wielu testów, których nie będę mógł przeprowadzić. Żeby zrobić to dobrze, trzebaby wg mnie zmienić koncepcję, bo tutaj zbyt często pojawia się zależność od czujnika ruchu. Jest na forum anglojęzycznym scena

Please login or register to see this link.

. Prawdopodobnie dużo lepiej się sprawdzi w skomplikowanych konfiguracjach.

Link to comment
Share on other sites

  • 0

Panowie możecie mi pomóc jak w tej scenie dodać drugiego fgd-212 dimmer'a

 

Please login or register to see this code.

 

Link to comment
Share on other sites

  • 0

 

to było

 

Please login or register to see this code.

powinno byc

 

Please login or register to see this code.

 

powinno działac z lamp / dimmer / rgb

 

 

 

PS: Zamiast 99 można ustawic dowolną wartośc.

 

noc value = 10
rano value = 15
dzień value= 1
wieczór value = 99

 

99 = max

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...