Jump to content
  • 0
MattyO

Flashing light scene Lua code loop

Question

Could anyone please help me withe the code I need to loop lua code for a set amount of time. I am trying to make a scene that will flash lights for an x amount of time. 

 

Thanks so much Matt 

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I use this for my HUE lights flashing red while the alarm gets activated. Activated alarm sets the alarm state to "alarm" and when de-activated this variable switches to "disarmed":

 

 

--[[
%% autostart
%% properties
%% events
%% globals
Alarm_State
--]]

if (fibaro:countScenes() > 2) then
  fibaro:abort()
  fibaro:debug ('meer scenes dan toegestaan')
end

local startSource = fibaro:getSourceTrigger();

--fibaro:setGlobal("Alarm_State", "Alarm");

if fibaro:getGlobalValue("Alarm_State") == "Alarm" then 
    
  while true do
    
    if fibaro:getGlobalValue("Alarm_State") == "Disarmed" then 
      --groen
    fibaro:call(271, "setSlider", "1", "99");
    fibaro:call(271, "setSlider", "2", "38");
    fibaro:call(271, "setSlider", "3", "99"); 
    
    fibaro:call(212, "setSlider", "1", "99");
    fibaro:call(212, "setSlider", "2", "38");
    fibaro:call(212, "setSlider", "3", "99"); 
      
    fibaro:call(335, "setSlider", "1", "99");
    fibaro:call(335, "setSlider", "2", "15");
    fibaro:call(335, "setSlider", "3", "99"); 
    fibaro:debug('disarmed, groen')  
      
     fibaro:abort()
end
    
    
  --rood flashing
    fibaro:setGlobal("Alarm_State", "Alarm");
    fibaro:call(271, "setSlider", "1", "99");
    fibaro:call(271, "setSlider", "2", "99");
    fibaro:call(271, "setSlider", "3", "99");
     
    fibaro:call(212, "setSlider", "1", "99");
    fibaro:call(212, "setSlider", "2", "99");
    fibaro:call(212, "setSlider", "3", "99");
    
    fibaro:call(335, "setSlider", "1", "99");
    fibaro:call(335, "setSlider", "2", "99");
    fibaro:call(335, "setSlider", "3", "99");
    
    fibaro:sleep(1000)
      
    fibaro:call(271, "setSlider", "1", "20");
      fibaro:call(212, "setSlider", "1", "20");
    fibaro:call(335, "setSlider", "1", "20");
    
    fibaro:sleep(1000)
    
      fibaro:call(271, "setSlider", "1", "99");
       fibaro:call(212, "setSlider", "1", "99");
    fibaro:call(335, "setSlider", "1", "99");

    
    
  fibaro:sleep(1000)
    fibaro:call(271, "setSlider", "1", "20");
    fibaro:call(212, "setSlider", "1", "20");
    fibaro:call(335, "setSlider", "1", "20");
  
    fibaro:sleep(1000)
  
  fibaro:debug('lamp alarm')

  
end


  
end

Share this post


Link to post
Share on other sites
  • 0
  • Inquirer
  • Thanks Very Much I will give that a go

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    ×