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

Jak wpisać do kodu aby światło zapalało się na wybrany kolor jak to jest listwa RGBW


Mariio82

Question

Witam

jak wpisać do kodu aby światło zapalało się na wybrany kolor jak to jest listwa RGBW 

chodzi mi o moc światła np. kolor W na 50% jeśli zakres jest od 0 do 255

 niżej wklejam kod 

--[[
%% 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

proszę o pomoc

 

czy ktoś już dodał drugi czujnik ruch ?

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • dzięki za pomoc

    a czy coś da się zrobić z tym kodem żeby był aktywowany od dwóch czujników ruch?

    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...