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

turnoff lights when multiple motion sensors in a room aren't breached for a few minutes.


Question

Posted

Hi all,

 

I noticed the large amount of smart light-scenes in this forum, but i didn't find the answer i was looking for. 

 

I created a scene which checks (runs every 5 min by mainloop from @Sankotronic) multiple motion sensor if they aren't breached for (lets say) 30 minutes. When true then all lights in the same room as the motionsensor will turn off. 

 

Problem is that some rooms have multiple motion sensors and currently if 1 of the sensors aren't breached for 30 min, the lights in that room will be turned off,  but what i'm lookinfg for is when all sensors in 1 room aren't breached for 30 minutes, then the lights are turned off. 

 

Current scene:

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

 

if (fibaro:countScenes() > 1) then fibaro:abort() end; 
local hc=fibaro
local startSource = fibaro:getSourceTrigger();

 

-- Locals
local lightID = {191, 33, 57, 116}
local motionID = {79, 102, 107, 50, 203, 194}
local movementMax = 30 -- in minutes

 

local motionRoom = "Null"

 

-- Mainscene
if(#motionID > 0)
   then
   for i=1,#motionID do 
      if ( (tonumber(os.time()) - tonumber(hc:getValue(motionID, "lastBreached"))) >= (tonumber(movementMax)*60) )
         then 
         motionRoom = hc:getRoomNameByDeviceID(motionID)
         if(#lightID > 0)
            then
            for z=1,#lightID do 
               if (hc:getRoomNameByDeviceID(lightID[z])==motionRoom 
               and tonumber(hc:getValue(lightID[z], "value")) > 0)
                  then 
                  hc:call(lightID[z], "turnOff"); 
                  hc:debug("turned off light - " ..hc:getName(lightID[z]).." ("..hc:getRoomNameByDeviceID(lightID[z])..")")
               end 
            end
         end
      end 
   end
end

 

Thanks in advance!

 

Rick

7 answers to this question

Recommended Posts

  • 0
Posted (edited)

I have tried as well to solve similar issues with Lua, but I'm not s SW person.

May I suggest take a look on All-in-One Scene by @cag014 (in download center) it a matter of seconds to do what you need.

 

Edited by AR27690
  • 0
Posted
1 hour ago, AR27690 said:

I have tried as well to solve similar issues with Lua, but I'm not s SW person.

May I suggest take a look on All-in-One Scene by @cag014 (in download center) it a matter of seconds to do what you need.

 

 

...and with

Please login or register to see this link.

the rule look like

Please login or register to see this code.

the old behaviour, if one sensor is safe for 30min, would have the last rule look like

Please login or register to see this code.

 

  • Like 1
  • 0
Posted

@rickydehaas you forgot to add to props at header motions id's

  • 0
  • Inquirer
  • Posted
    14 minutes ago, jgab said:

     

    ...and with

    Please login or register to see this link.

    the rule look like

    Please login or register to see this code.

    the old behaviour, if one sensor is safe for 30min, would have the last rule look like

    Please login or register to see this code.

     

     

    Thanks, Correct me if i’m wrong, but this won’t fix my problem: Turning off the lights in 1 room when both motion sensors havent been breached in 30 min

    17 minutes ago, 10der said:

    @rickydehaas you forgot to add to props at header motions id's

     Thanks for looking into it @10der. The scene will be runned every 5 min (scheduled by another scene).

     

    problem i’m facing with my script is that currently lights in 1 room will be turned off, when 1 of multiple sensors is not breached in 30 min. Because i’m using multiple sensors in 1 room, i need to rewrite the script that lights in a single room only will be turned off when ALL motion sensors in that room ar not breached in 30 min.

    • 0
    Posted (edited)
    41 minutes ago, rickydehaas said:

     

    Thanks, Correct me if i’m wrong, but this won’t fix my problem: Turning off the lights in 1 room when both motion sensors havent been breached in 30 min

     

    if motionID are the sensors in the room in question, trueFor(00:30,motionID:safe) returns true if all sensors are safe for 30min , which is what you wanted, or?

    If motionID is a list of more sensors than the ones in the room you want to check, the rule becomes bit more complex because you have to filter per room. However, I would recommend to 

    have a list of sensors per room.

     

    Edited by jgab
    • Like 1
    • 0
  • Inquirer
  • Posted
    2 minutes ago, jgab said:

     

    if montionID are the sensors in the room in question, trueFor(00:30,motionID:safe) returns true if all sensors are safe for 30min , which is what you wanted, or?

    If motionID is a list of more sensors than the ones in the room you want to check, the rule becomes bit more complex because you have to filter per room. However, I would recommend to 

    have a list of sensor per room.

     

    @jgabThe second/last behaviour your mentioned. The scene uses multiple lights (lightID) and sensors (motionID) available in multiple rooms. The goal was to write a simple scene for a few selected lights in multiple rooms and turn them off when there is no motion in the room for a specific light for more then 30 min... when i was writing the scene i forgot that some rooms have multiple sensors, which made it more complex.

     

    Will check eventrunner in the next days if it will fit my needs. Thanks for looking into it!

    • 0
    Posted

    @jgabThanks,

    I will implement that too.

    Not to switch light off but going into very dimmed setting. Since we have all led and HUE lamps it will not cost so much to let them light on small Wattage.

    The EVENT RUNNER is great and simple to code.

    //Sjakie

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