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
Fro 1
Hello!
I need help to create a scene in which the switch not connected to the light source will imitate the switch that actually turns on this light source. I have a switch (DummySwitch) next to the bed, which I would like to be able to turn off the light controlled by the switch next to the door. Of course, I also need cross on/off possibility: when one can turn off the other.
I did not find similar scene, so I tried to write it myself, but I can't do it
All in all, everything works except when I'm trying to turn off the light by DummySwitch.
Please, I need Your Help.
I have a Fibaro HC2 for a few days, and this is the first scene in LUA which I try to make - so please: be gentle
--[[
%% 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
Edited by FrodummyTurnedOff
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
typo
2 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.