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
Lenny212 2
Hi,
I couldn't delete my question so I edited it and turned it into a description of what I did.
---------------------------------------------------------------------------------------------------------------------------------
I want to set two global variables in two separate Lua scenes. (Both are manually triggered)
I then want to access those global variables in another scene. (Triggered based on time of day matching global variables)
----------------------------------------------------------------------------------------------------------------------------------
I created a variable called Time and a LUA scene called TimeTrigger.
--[[
%% properties
%% autostart
%% events
%% globals
--]]
if (fibaro:countScenes()>1)
then
fibaro:debug('Scene already running')
fibaro:abort()
end
while (true) do
local currentDate = os.date('*t')
local currentTime = string.format('%02d', currentDate.hour) .. ':' .. string.format('%02d', currentDate.min)
fibaro:debug('Time = ' .. currentTime)
fibaro:setGlobal('Time', currentTime)
fibaro:sleep(60*1000)
end
------------------------------------------------------------------------------------------------------------------------------------------
I then created a LUA scene called 6amWakeUp (and 5am, 7am, 8am, 9am)
--[[
%% properties
%% events
%% globals
--]]
fibaro:setGlobal('WakeUpHour', '06');
------------------------------------------------------------------------------------------------------------------------------------------
I then created a LUA scene called 30WakeUp (and 00, 15, 45)
--[[
%% properties
%% events
%% globals
--]]
fibaro:setGlobal('WakeUpMinute', '30');
------------------------------------------------------------------------------------------------------------------------------------------
I then created the scene to open roller shutters/blinds in the morning
--[[
%% properties
%% events
%% globals
Time
--]]
local time = fibaro:getGlobal('Time')
local WakeUpHour = fibaro:getGlobal('WakeUpHour')
local WakeUpMinute = fibaro:getGlobal('WakeUpMinute')
local WakeUpTime = WakeUpHour .. ':' .. WakeUpMinute
if
(
(time == WakeUpTime)
and
(tonumber(fibaro:getGlobalValue("WakeUp")) == tonumber("1")) --[[This is a 0/1 toggle variable so I can turn off the morning wake up--]]
)
then
fibaro:call(53, "open");
fibaro:call(56, "open");
fibaro:sleep (10000)
fibaro:call(222, "open");
fibaro:sleep (10000)
fibaro:call(74, "open");
...etc
end
----------------------------------------------------------------------------------------------------------------
Solved issue and changed text from question to solution
Link to comment
Share on other sites
5 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.