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

ALL OFF lighting scene example


seiq

Question

Thought this easy LUA scene to turn off all lights using the new(ish) fibaro:getDevicesId() function might be helpful to others.

Please login or register to see this code.

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

This is great... Thanks Seiq 

sample with s2 button on dimmer as trigger

dimmer id 105

single push on s2 scene id=26

 

 

 

--[[
%% properties
105 sceneActivation
%% events
%% globals
--]]
 
local lightID = 105
 
local scene = fibaro:getValue(lightID, 'sceneActivation')

end                                                                                                  l

if (scene == '26') then 
  end
local ids = fibaro:getDevicesId(
  {
    interfaces = {
      "light",
    },
    properties = {
      dead = false,  
    },
    enabled = true,
    visible = true, -- optional
  }
);
    
-- loop through light ids
for i, id in ipairs(ids) do
    fibaro:debug("Turning off " .. fibaro:getName(id));
    -- turn light off
    fibaro:call(id, "turnOff");
end

 

Edited by Jamie mccrostie
Link to comment
Share on other sites

  • 0
  • Inquirer
  • Np @Jamie mccrostie

    That scene will turn off all lights no matter which button you push as the for loop is outside your if statement.

     

    Also, find out how to use

    Please login or register to see this link.

    to save duplicating id's and property types

     

    Example with these modifications:

     

    --[[
    %% properties
    105 sceneActivation
    %% events
    %% globals
    --]]
                                                                                   

    local sourceTrigger = fibaro:getSourceTrigger()

    -- fibaro:debug("sourceTrigger = " .. json.encode(sourceTrigger)) -- uncomment to debug contents of sourceTrigger table

     

    local scene = fibaro:getValue(sourceTrigger.deviceID, sourceTrigger.propertyName)

     

    if (scene == '26') then
      local ids = fibaro:getDevicesId(
        {
          interfaces = {
            "light",
          },
          properties = {
            dead = false,  
          },
          enabled = true,
          visible = true, -- optional
        }

      );
        
      -- loop through light ids
      for i, id in ipairs(ids) do
        fibaro:debug("Turning off " .. fibaro:getName(id));
        -- turn light off
        fibaro:call(id, "turnOff");
      end

    end

    Link to comment
    Share on other sites

    • 0

    Have tried this and get Debug Line115: attempt to concatenate local "propetyName" (a nil Value)

    Which i especially dont understand when the scene only has 34 lines.

    However the scene still seems to work fine.

    cheers jamie

    Edited by Jamie mccrostie
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Should be "propertyName"

     

    The line 115 error would be reported from within the LUA engine rather than the scene itself.

    Edited by seiq
    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...