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: dublowanie zachowania włącznika podłączonego do oświetlenia przez niepodłączony


Fro

Question

Witam!

Potrzebuję pomocy do stworzenia sceny w której włącznik który nie jest połączony do źródła światła będzie naśladował włącznik rzeczywiście włączający to źródło światła ale również wymuszał na nim naśladowanie siebie. Mam włącznik (DummySwitch) przy łóżku którym chciałbym móc wyłączyć światło które jest sterowane włącznikiem przy drzwiach. Oczywiście również krzyżowo - zapalić jednym a wyłączyć drugim. 

Nie znalazłem nic podobnego, więc spróbowałem napisać sam, ale mnie to przerosło :( W sumie wszystko działa poza sytuacją gdy próbuje wyłączyć światło DummySwitch'em - światło gaśnie, rzeczywisty wyłącznik się wyłącza, ale DummySwitch odbija i pozostaje na ON :(

Bardzo proszę  wskazanie gdzie popełniam błąd.

Mam centralkę Fibaro od kilku dni, a to pierwsza scena w LUA którą próbuje napisać - więc proszę o wyrozumiałość :)

 

 

--[[
%% properties
740 value
736 value
%% events
%% globals
--]]


-----------------------------------------------------------------------------
  fibaro:debug("SCENE START --------------------------")
  fibaro:debug("sceneInstance: "..fibaro:countScenes())
if 
  fibaro:countScenes() > 1 
 then 
  fibaro:debug("SCENE ABORT --------------------------") 
  fibaro:abort() 
end
------------------------------------------------------------------------------

local startSource = fibaro:getSourceTrigger();

local switchID     = 736
local dummyID    = 740

local switchTurnedOn   =  (tonumber(fibaro:getValue(switchID,  "value")) > 0);
local dummyTurnedOn  =  (tonumber(fibaro:getValue(dummyID, "value")) > 0);

local switchTurnedOff  =  (tonumber(fibaro:getValue(switchID,  "value")) == 0);
local dummyTurnedOff =  (tonumber(fibaro:getValue(dummyID, "value")) == 0);

local isTvLightOn     =  (tostring(fibaro:getGlobal("isTvLightOn")) == "true");
local isTvLightOff    =  (tostring(fibaro:getGlobal("isTvLightOn")) == "false");


if
 switchTurnedOn
  then
   fibaro:debug("isTvLightOn: "..tostring(isTvLightOn))
   fibaro:debug("Real Switch ON - turnOn dummy one")
   fibaro:call(dummyID, "turnOn");
   fibaro:debug("Dummy Switch ON")
   fibaro:setGlobal("isTvLightOn", "true");
   fibaro:debug("isTvLightOn: "..tostring(isTvLightOn))
   fibaro:debug("-changes into:")
   fibaro:debug(fibaro:getGlobal("isTvLightOn"))
  end

 if
  switchTurnedOff and isTvLightOn
   then
    fibaro:debug("isTvLightOn: "..tostring(isTvLightOn))
    fibaro:debug("Real Switch OFF - turnOff dummy one")
    fibaro:call(dummyID, "turnOff");
    fibaro:debug("Dummy Switch OFF")
    fibaro:setGlobal("isTvLightOn", "false");
    fibaro:debug("isTvLightOn: "..tostring(isTvLightOn))
    fibaro:debug("-changes into:")
    fibaro:debug(fibaro:getGlobal("isTvLightOn"))
  end


if
 dummyTurnedOn 
  then
   fibaro:sleep(1000)
    if isTvLightOff
        then
         fibaro:debug("isTvLightOn: "..tostring(isTvLightOn))
         fibaro:debug("Dummy Switch ON - turnOn real one")
         fibaro:call(switchID, "turnOn");
         fibaro:debug("Real Switch ON")
         fibaro:debug("isTvLightOn: "..tostring(isTvLightOn))
         fibaro:debug("-changes into:")
         fibaro:debug(fibaro:getGlobal("isTvLightOn"))
      elseif
         isTvLightOn
        then
         fibaro:abort()
       end
      end

if
 dummyTurnedOff
  then
   fibaro:sleep(1000)
    if isTvLightOn
        then
         fibaro:debug("isTvLightOn: "..tostring(isTvLightOn))
         fibaro:debug("Dummy Switch OFF - turnOff real one")
         fibaro:call(switchID, "turnOff");
         fibaro:debug("Real Switch OFF")
         fibaro:debug("isTvLightOn: "..tostring(isTvLightOn))
         fibaro:debug("-changes into:")
         fibaro:debug(fibaro:getGlobal("isTvLightOn"))
      elseif
         isTvLightOff
        then
         fibaro:abort()
       end
      end

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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