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

LUA script to turn off all downstairs lights


jasonway

Question

Hi, I currently use the script (Scene) below to turn off all lights when going to sleep. The problem is sometimes my adult children are still awake upstairs. How would I modify scene to turn off only downstairs lights?

 

HC2 - Running latest version

 

I thought of using the description field in devices and evaluating but can't work out the code. Help!

 

--[[
%% properties
%% events
%% globals
--]]
local ids = fibaro:getDevicesId(
  {
    interfaces = {
      "light",
    },
    properties = {
      dead = false,  
    },
    enabled = true,
    visible = true, -- optional
    --userDescription ~= "", -- attempt to evaluate if user description in device is not nil.
  }
);
    
-- 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

 

Thanks

Jason

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

The topic has been moved from "

Please login or register to see this link.

" to "

Please login or register to see this link.

".

 

Temat został przeniesiony z "

Please login or register to see this link.

" do "

Please login or register to see this link.

".

Link to comment
Share on other sites

  • 0

Jason, you can try the code below, should work (not at home so cannot test right now).

Please login or register to see this code.

There is a thread describing in detail how to use these functions getDevicesIds and callGroupAction (especially the contributions from @petergebruers:-) ). Confused me as well...

 

 

Best, Rene.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi and Thanks Rene, I tried what you suggested and at first it didn't work but using the discussion you pointed me to I was able to get it functioning as desired. Thanks Again.

     

    Jason

     

    --[[
    %% properties
    %% events
    %% globals
    --]]

    local data =
    {
       args = { 1 },
       filters =
       {
          {
             filter = "deviceID",
             value = { 454, 45, 452, 51, 466, 471, 113, 26, 459, 482, 294, 302, 7, 386, 131, 86, 55, 112 }
          }
       }
    }

    local devices = fibaro:callGroupAction("turnOff", data)

    print(json.encode(devices))
    -- 454 --Family
    -- 45 --Lounge
    -- 452 --Lounge Lamp
    -- 51 --Meals
    -- 466 --Kitchen
    -- 471 --Kitchen LED
    -- 113 --Laundry
    -- 26 --Hall
    -- 459 --Entry
    -- 482 --Master Bedroom
    -- 294 --Ensuite LED
    -- 302 --Ensuite Exhaust
    -- 7 --Gamnes
    -- 386 --Stairs
    -- 131 --Air Compressor
    -- 86 --FrontYard
    -- 55 --Patio
    -- 112 --SideYard

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