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


  • 4

HC3 no motion for X time = lights off, how to?


Pete123

Question

Hi,

 

How do you configure a scene that will turn on lights when motion and does not turn off until motion sensor has been safe for X time?

I am looking for both Lua and block options, if available.

Until now I have only found option for "delay" meaning lights will turn off after given time no matter if there has been motion during "delay" period.

 

Hope someone has found a solution for this.

Link to comment
Share on other sites

Recommended Posts

  • 0

 

Hi

Below scene works perfect. Thanks for all contributors.

But,  I would like to modify it to include the light switch as well. If I use the light switch manually, the light will stay on until I turn it off manually. If I don't use the switch, the light will work as in the current scene (until motion sensors are breached + maxTime). How to do that?

 

DECLARATIONS

{
  conditions = { {
      id = 78,
      isTrigger = true,
      operator = "==",
      property = "value",
      type = "device",
      value = true
    }, {
      id = 263,
      isTrigger = true,
      operator = "==",
      property = "value",
      type = "device",
      value = true
    } },
  operator = "any"
}

 

Actions

-- This scene turns on one or more lights: 
--    when Lux level is below a certain level (see DECLARATIONS) and 
--    shows the Lux level of one ore more Lux sensors and 
--    turns off the lights after a certain time (maxTime), 
--    unless there is motion from one or more Motion sensors
 
-- Please enter the right ID's (if more than one, seperate by ",") and the prefered maxTime for the lights to stay on 
 
local light = {26, 62} -- ID's of the lights to turn on
local motion = {78, 263} -- ID's of the Motion sensors to check if they are breached
local lux = {80, 265} -- ID's of the Lux sensors to (only) show the lux level
local maxTime = 1*60 -- Maximum time the sensor should be safe before turning off (n*60 where n is minutes)
local sleepTime = 5 -- Time in seconds between each check of the Motion sensor (default = 5)
local debug_TAG = "Woonkamer licht" -- Tag for the debug messages
 
-- Below here no changes are necessary
 
for i in pairs(light) do -- Turn on the lights
  fibaro.debug(debug_TAG,"Turning on (ID " ..light[i] ..") " ..fibaro.getName(light[i]) .." for " ..maxTime .." seconds")
  fibaro.call(light[i],"turnOn")
end
 
for i in pairs(lux) do -- Show the lux level of the Lux sensors
  fibaro.debug(debug_TAG,"Current Lux level " ..lux[i] .." " ..fibaro.getName(lux[i]) ..": " ..fibaro.getValue(lux[i],"value"))
end
 
local safeTime = 0
while safeTime < maxTime do -- Loop until maxTime is reached
  fibaro.sleep(sleepTime*1000)                 
  safeTime=safeTime+sleepTime 
  fibaro.debug(debug_TAG,"Counting up safeTime " ..safeTime .." to maxTime " ..maxTime)
  for i in pairs(motion) do 
    if fibaro.getValue(motion[i],"value") then -- Check if Motion sensors are breached
       fibaro.debug(debug_TAG,"Reset by Motion sensor " ..motion[i] .." " ..fibaro.getName(motion[i]))
       safeTime = 0 -- Reset safeTime to zero
    end
  end
end 
  
for i in pairs(light) do -- Counted down to maxTime, turn off the lights
  fibaro.debug(debug_TAG, "Turning off " ..light[i] .." " ..fibaro.getName(light[i]))
  fibaro.call(light[i],"turnOff") 
end
  • Like 2
Link to comment
Share on other sites

  • 0
On 6/26/2022 at 7:07 PM, AWU said:

 

Hi

Below scene works perfect. Thanks for all contributors.

But,  I would like to modify it to include the light switch as well. If I use the light switch manually, the light will stay on until I turn it off manually. If I don't use the switch, the light will work as in the current scene (until motion sensors are breached + maxTime). How to do that?

 

DECLARATIONS

{
  conditions = { {
      id = 78,
      isTrigger = true,
      operator = "==",
      property = "value",
      type = "device",
      value = true
    }, {
      id = 263,
      isTrigger = true,
      operator = "==",
      property = "value",
      type = "device",
      value = true
    } },
  operator = "any"
}

 

Actions

-- This scene turns on one or more lights: 
--    when Lux level is below a certain level (see DECLARATIONS) and 
--    shows the Lux level of one ore more Lux sensors and 
--    turns off the lights after a certain time (maxTime), 
--    unless there is motion from one or more Motion sensors
 
-- Please enter the right ID's (if more than one, seperate by ",") and the prefered maxTime for the lights to stay on 
 
local light = {26, 62} -- ID's of the lights to turn on
local motion = {78, 263} -- ID's of the Motion sensors to check if they are breached
local lux = {80, 265} -- ID's of the Lux sensors to (only) show the lux level
local maxTime = 1*60 -- Maximum time the sensor should be safe before turning off (n*60 where n is minutes)
local sleepTime = 5 -- Time in seconds between each check of the Motion sensor (default = 5)
local debug_TAG = "Woonkamer licht" -- Tag for the debug messages
 
-- Below here no changes are necessary
 
for i in pairs(light) do -- Turn on the lights
  fibaro.debug(debug_TAG,"Turning on (ID " ..light[i] ..") " ..fibaro.getName(light[i]) .." for " ..maxTime .." seconds")
  fibaro.call(light[i],"turnOn")
end
 
for i in pairs(lux) do -- Show the lux level of the Lux sensors
  fibaro.debug(debug_TAG,"Current Lux level " ..lux[i] .." " ..fibaro.getName(lux[i]) ..": " ..fibaro.getValue(lux[i],"value"))
end
 
local safeTime = 0
while safeTime < maxTime do -- Loop until maxTime is reached
  fibaro.sleep(sleepTime*1000)                 
  safeTime=safeTime+sleepTime 
  fibaro.debug(debug_TAG,"Counting up safeTime " ..safeTime .." to maxTime " ..maxTime)
  for i in pairs(motion) do 
    if fibaro.getValue(motion[i],"value") then -- Check if Motion sensors are breached
       fibaro.debug(debug_TAG,"Reset by Motion sensor " ..motion[i] .." " ..fibaro.getName(motion[i]))
       safeTime = 0 -- Reset safeTime to zero
    end
  end
end 
  
for i in pairs(light) do -- Counted down to maxTime, turn off the lights
  fibaro.debug(debug_TAG, "Turning off " ..light[i] .." " ..fibaro.getName(light[i]))
  fibaro.call(light[i],"turnOff") 
end

 

 

@AWU did you manage to get an answer to your question on using the manual light switch to kill the scene? Just migrated to HC3 from HC2 and am lost.  The Very Smart Lights script in HC2 worked flawlessly, is there something like that for HC3? 

Link to comment
Share on other sites

  • 0
On 2/16/2020 at 5:07 AM, Pete123 said:

Hi,

 

How do you configure a scene that will turn on lights when motion and does not turn off until motion sensor has been safe for X time?

I am looking for both Lua and block options, if available.

Until now I have only found option for "delay" meaning lights will turn off after given time no matter if there has been motion during "delay" period.

 

Hope someone has found a solution for this.

 

Again - disclaimer that I'm a total newbie in HC3 - but can I ask if using Associations for the motion sensor works for the subject question?  Once you associate the required light, you set parameter 6 to the required time and it would work?  And if you need more lights you either add more associations or use the light to trigger a scene with additional actions?  

 

I'm sure the answer is a lot more obvious than what I'm seeing but I just want to enhance my knowledge of HC3

 

Link to comment
Share on other sites

  • 0
On 6/28/2020 at 4:59 AM, SmartHomeEddy said:

@theuksbest

 

My switch overrides the scene. So the light stays on, if I use the switch. I don’t want it to go off, if I switch it manually. That drives me crazy if I want to work in the garage ?
 

(But to use the switch, I am in range of the motion sensor) 

 

The declaration is now

lux less than AND motion

 

Maybe you could change the declarations with this logic

 

switch on

OR

(lux less than AND motion)

 

Within the action there is only a check for motion. So if you turn on the light manually, it goes off after the timer unless there is motion, no matter the lux. 

 

@SmartHomeEddy i've just used the code you posted and everything works perfectly - but i just have one question on the manual switch part.  How did you implement the override functionality you mentioned?  I want it to work exactly like you mentioned - if i'm gonna be in the room for long (at my desk working for example where the motion sensor wont detect obvious movements), i want to be able to switch of this scene manually.  How do i kill the countdown using a physical switch?  

 

Thanks! 

Link to comment
Share on other sites

  • 0

I have a simple setup, next to the motion scene running I have a manual switch. If I turn the switch on, the light stays on until I turn off the switch. 

Link to comment
Share on other sites

  • 0
9 hours ago, SmartHomeEddy said:

I have a simple setup, next to the motion scene running I have a manual switch. If I turn the switch on, the light stays on until I turn off the switch. 

@SmartHomeEddy

Yeah i have a manual switch as well, question is - how do i kill the motion scene with the manual switch if i intend to stay in the room to work? do you have to add a condition to your code?  

Link to comment
Share on other sites

  • 0

I don't kill the motion scene, my manual switch overrides the scene. The light just stays on until I switch it off with the manual switch. 

Link to comment
Share on other sites

  • 0
11 minutes ago, SmartHomeEddy said:

I don't kill the motion scene, my manual switch overrides the scene. The light just stays on until I switch it off with the manual switch. 

hmm.. maybe im missing something here but if i hit the manual switch while the scene is running, the scene will just trigger again when the motion sensor is breached and then it turns off after x minutes.  forgive the noob question but how do you 'override' it? 

Link to comment
Share on other sites

  • 0

I haven't done a thing to have this working. Only difference is I can turn the manual switch on before the scene triggers. 

 

BTW I hardly use this feature. Most of the time the light turns on when I need it to turn on. 

 

You could raise the maxTime, to give the motion sensor more time to reset the timer. Or consider a motion radar like the Aqara FP1 (but more work the get it set up). 

Link to comment
Share on other sites

  • 0
7 hours ago, SmartHomeEddy said:

I haven't done a thing to have this working. Only difference is I can turn the manual switch on before the scene triggers. 

 

BTW I hardly use this feature. Most of the time the light turns on when I need it to turn on. 

 

You could raise the maxTime, to give the motion sensor more time to reset the timer. Or consider a motion radar like the Aqara FP1 (but more work the get it set up). 

 

but if you turn on the manual switch, when the motion sensor is triggered doesnt the scene start to countdown, meaning if you don't move within maxTime it will shut off?  

Link to comment
Share on other sites

  • 0


Thanks for this lovely script. ❤️ 

I was trying to do something similar but without succes.  Now its so smooth.

But as others i want to be abel to cancel the countdown in the scrip, with say an variabel.

Like.. "abort countdown if  variabel "Tv is on"" and been trying to mix various command and nothing works.

Any have any suggestion?

Link to comment
Share on other sites

  • 0


Thanks for this lovely script. ❤️ 

I was trying to do something similar but without succes.  Now its so smooth.

But as others i want to be abel to cancel the countdown in the scrip, with say an variabel.

Like.. "abort countdown if  variabel "Tv is on"" and been trying to mix various command and nothing works.

Any have any suggestion?

 

UPPDATED!

I have find a way

Solution is this scrip

hub.scene("kill", {832})   and i put it in the scene who starts the Tv.( and the count down is already running)
 

Please login or register to see this code.

Link to comment
Share on other sites

  • 0
W dniu 17.03.2023 o 18:00, Elakagubben napisał:

If anyone has a simpler solution, it would be greatly appreciated

 

 

Well, I have another solution. Although it is a bit longer, I hope you find it simpler.

 

Triggers:

Please login or register to see this code.

 

Scene code:

Please login or register to see this code.

 

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