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?


Question

Posted

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.

Recommended Posts

  • 0
Posted

Just to try if the logics works for you, replace the bottom part with: 

 

if fibaro.getValue(74, "value") and fibaro.getValue(325, “value”) then 

  fibaro.debug(debug_TAG, "Leave the lights on")

else

  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

end

 

 

  • 0
Posted

Thanks a lot for your help 

On 11/29/2020 at 8:36 PM, SmartHomeEddy said:

Just to try if the logics works for you, replace the bottom part with: 

 

if fibaro.getValue(74, "value") and fibaro.getValue(325, “value”) then 

  fibaro.debug(debug_TAG, "Leave the lights on")

else

  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

end

 

 

Thanks for the code. I get the logic now. Thats exactly what i needed...

  • 0
Posted

Good luck. Let's see if the value in the global variable is the right format, number versus string. Maybe you have to do something with tonumber() and tostring(). 

 

 

  • 0
Posted

Hi SmartHomeEddy,

 

I coppied the light script to all the rooms and it works wonderfully now! Thanks for that. In order to create different behavior during night and day time I would like to add the light level to the code. 

 

I tried to add this:

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(light) do -- Set dimming level
  fibaro.debug(debug_TAG,"Dimming level (ID " ..light[i] ..") " ..fibaro.getName(light[i]) .." for " ..maxTime .." seconds")
fibaro.call(light[i], 'setValue', 48)
end

 

Obviously the scene did not work. Could you point out what I should change?

 

 

  • 0
Posted

Could you try to replace the ‘ with a “ ?

 

fibaro.call(light[i],”setValue”,48)

 

(sometimes with copy-paste it gives an issue)

  • 0
Posted

Hi, I'm totally new to this, so forgive me if this is terribly incorrect.

 

Although I understand that more code could provide more functionality and reliability, a simple solution to the opening question is to switch on the lights and set a timeout of the desired duration to switch them off. If the motion is not breached, the lights are switched off. If the motion is breached, the scene is triggered again and the running instance is killed, so the lights are not switched off for another complete cycle. Of course the scene must have the "Allow to restart a running scene" set to Yes.

 

It works well for me with three lines of LUA. It can be done with a couple of blocks as well, this is actually similar to the solution proposed at the very beginning of the post by @marius de jong, but without the separate trigger on the motion going back to Safe.

 

Do you see any drawback?

 

Thanks!

  • 0
Posted

Hi,

 

I also want to create a scene that turns the lights off after a given time without any motion detected. It seems “Magic Scenes” provides a simple built-in feature to do this, where you can choose the “Not tripped for x minutes” option. However, I have multiple sensors in my living room, and I only want the lights to go off if no motion is detected in any of the sensors. But Magic scenes only allow one triggering device. Is there any way to link the motion sensors together into a “master motion sensor” which is tripped if any of the belonging sensors detect motion?

 

Fredrik

  • 0
Posted

yes, I have created Virtual sensors AIO and there you can put together all your sensors.

  • 0
Posted
1 hour ago, petrkl12 said:

yes, I have created Virtual sensors AIO and there you can put together all your sensors.


Hmmm.. I’m on HC2. Is it possible to create virtual sensors in HC2?

  • 0
Posted

Yes, but somebody has to create virtual device

  • 0
Posted
On 4/28/2021 at 9:53 PM, petrkl12 said:

Yes, but somebody has to create virtual device

 

I see. So this means that, currently, there is no way to utilize the "Not tripped more than X minutes" with multiple motion sensors in HC2?

 

More in general, why is the "Not tripped more than X minutes" option available only in Magic Scenes and not in block scenes?

  • 0
Posted (edited)
30 minutes ago, fredrikbk said:

 

I see. So this means that, currently, there is no way to utilize the "Not tripped more than X minutes" with multiple motion sensors in HC2?

 

More in general, why is the "Not tripped more than X minutes" option available only in Magic Scenes and not in block scenes?

Well, you can always write a Lua scene - or use someone else's already written scene.

There are Lua scenes like @Sankotronic Very Smart Light scene.

@cag014All-in-on-scene

and my own EventRunner scene.

In my scene that task is defined as

Please login or register to see this code.

 

Edited by jgab
  • 0
Posted
14 minutes ago, jgab said:

Well, you can always write a Lua scene - or use someone else's already written scene.

There are Lua scenes like Sankotronic's Very Smart Light scene.

Cag014's All-in-on-scene

and my own EventRunner scene.

In my scene that task is defined as

Please login or register to see this code.

 

 

Thank you for answering! 

Is this possible to implement without any knowledge of LUA? I guess this involves a bit more than simply pasting the above script in a new LUA scene without any other installments?

  • 0
Posted

So, I actually came up with a way to solve my problem without the use of LUA:

 

First, I defined two variables:

1. Motion room A: Yes/No

2. Motion room B: Yes/No

 

Second, I created two manual block-scenes without any triggers:

- BlockScene1: Set variable 'Motion room A' to No

- BlockScene2: Set variable 'Motion room B' to No

 

Thid, I created two automatic block-scenes triggered by the motion sensors:

- BlockScene3: Set variable 'Motion room A' to Yes if Sensor A is breached

- BlockScene4: Set variable 'Motion room B' to Yes if Sensor B is breached

 

Fourth, I created two Magic Scenes:

1. If Sensor A "Not tripped more than 30 minutes" -> Run 'BlockScene1'

2. If Sensor B "Not tripped more than 30 minutes" -> Run 'BlockScene2'

 

Finally, I created a block scene to turn the lights off if

'Motion room A' == No AND 'Motion room B' == No

 

It seems to working properly, although I sometimes receive notifications on too many instances. One downside is that the Magic Scene will not run again before the motion sensors are breached (meaning that it will not turn lights off if they're turned on without breaching any of the sensors).

 

Any thoughts (besides that I probably rather should have spent my time learning LUA instead of making cumbersome workarounds)? 

 

  • 0
Posted
On 29/11/2020 at 16:36, SmartHomeEddy said:

Apenas para testar se a lógica funciona para você, substitua a parte inferior por: 

 

se fibaro.getValue (74, "valor") e fibaro.getValue (325, "valor"), então 

  fibaro.debug (debug_TAG, "Deixe as luzes acesas")

senão

  para i em pares (luz) faça - Contagem regressiva até maxTime, apague as luzes

    fibaro.debug (debug_TAG, "Desligando" ..light [i] .. "" ..fibaro.getName (light [i]))

    fibaro.call (luz [i], "desligar") 

  fim

fim

 

 

@SmartHomeEddy, would it be possible to enter a code so that, upon finding that the other light is on, it resets the timer and starts counting time again and reading again until the other light goes out? like a looping? or would not be recommended? Thank you for your help.

  • 0
Posted

Hi @jorge rintaro

 

I am not sure I understand what you want it to do. Can you share your code where you want  to suspend the turnoff because an other light is on?

  • 0
Posted
2 hours ago, SmartHomeEddy said:

Oi @jorge rintaro

 

Não tenho certeza se entendi o que você quer fazer. Você pode compartilhar seu código onde deseja suspender o desligamento porque outra luz está acesa?

 
Hi, SmartHomeEddy,
This scene I believe is your creation (thanks, it helped a lot). At the end of the scene, after the motion sensor security time countdown, if the ID (69) and ID (70) lights are lit, the ID light (35) should NOT go out and the scene ends.
Is it possible for the scene to continue a new count of time until the ID (69) and ID (70) lights go out and therefore the ID light (35) goes out as well? or this "looping" would not be indicated? is it important to stop the scene? thanks
 
{
  conditions = { {
      id = 170,    -- Motion
      isTrigger = true
      operator = "==",
      property = "value",
      type = "device",
      value = true
    }, {
      id = 172,   -- LUX
      isTrigger = false,
      operator = "<=",
      property = "value",
      type = "device",
      value = 500,
          } },
  operator = "all"
}
 
local light = {35} -- ID's Lights Turn Off
local motion = {170-- ID's dos Motions
local maxTime = 1*60  -- Tempo máximo motion seguro
local sleepTime = 5 -- Intervalo de checagem status (default = 5)
local debug_TAG = "Lights Timer" -- Tag for the debug messages
 
for i in pairs(light) do -- Turn On lights
fibaro.debug(debug_TAG,"Turning on (ID " ..light[i] ..") " ..fibaro.getName(light[i]) .." for " ..maxTime .." seconds")
fibaro.call(light[i],"turnOn")
end
 
 
local safeTime = 0
while safeTime < maxTime do -- Loop até que maxTime seja alcançado
fibaro.sleep(sleepTime*1000)                 
safeTime=safeTime+sleepTime 
fibaro.debug(debug_TAG," Contando Tempo seguro " ..safeTime .." para maxTime " ..maxTime)
for i in pairs(motion) do 
if fibaro.getValue(motion[i],"value"then -- Check se Motion violado(s)
fibaro.debug(debug_TAG,"Reset o Motion sensor " ..motion[i] .." " ..fibaro.getName(motion[i]))
safeTime = 0 -- Reset safeTime (zera cronometro)
        end
    end
end 
if fibaro.getValue (69'value'or fibaro.getValue (70'value'then
fibaro.debug(debug_TAG, "Deixe as luzes acesas")
else
for i in pairs(light) do
fibaro.debug(debug_TAG, " Turning off  " ..light[i] .." " ..fibaro.getName(light[i]))
fibaro.call(light[i],"turnOff")
end
end
  • 0
Posted

Yes , it was my scene, but there were som alterations in this post, to never ever turnoff the light in case there was a light on. In your case, you want the light stay on if there is still motion or the two lights are on, otherwise turn the light off.

 

Also the scene is ment for more than one motion sensor and more than one light to turn on and off. But it works also with one, the loops "for i in pair" are not necessary. 

 

I thinks this will do the job. In this scene

 

Please login or register to see this code.

 

there is a check wether there is motion or both light are on. So if there is no motion and only one of the two lights is on, your light will go off. 

 

 

The full scene:

 

Please login or register to see this code.

 

Yo can use the same condition you already had.

 

I haven't checked the scene, let my know if it does ?

 

If it works, you probably want to turn off some of the debug messages, especially the one "Reset lights lit or o Motion sensor". 

 

 

 

 

  • 0
Posted
18 hours ago, SmartHomeEddy said:

Sim, era a minha cena, mas houve algumas alterações neste post, para nunca mais desligar a luz caso houvesse uma luz acesa. No seu caso, você deseja que a luz permaneça acesa se ainda houver movimento ou as duas luzes estiverem acesas; caso contrário, apague a luz.

 

Além disso, a cena é composta por mais de um sensor de movimento e mais de uma luz para ligar e desligar. Mas também funciona com um, os loops "for i in pair" não são necessários. 

 

Acho que isso vai dar certo. Nesta cena

 

Please login or register to see this code.

 

há uma verificação se há movimento ou se ambas as luzes estão acesas. Portanto, se não houver movimento e apenas uma das duas luzes estiver acesa, sua luz se apagará. 

 

 

A cena completa:

 

Please login or register to see this code.

 

Você pode usar a mesma condição que já tinha.

 

Eu não verifiquei a cena, deixe-me saber se faz  ?

 

Se funcionar, você provavelmente deseja desligar algumas das mensagens de depuração, especialmente a mensagem "Reinicializar luzes acesas ou o Sensor de movimento". 

 

 

 

 

Hello SmartHomeEddy,
Thanks a lot for the help. The scene works, but starts with this ERROR message (see screenshot).
but, trying to explain better what I need ......
1. movement violated (I will use 2 motion sensor)
2. turn on light 1, light 2 and light 3
3. end of time count
4. turns off light 1 and maintains the previous status of lights 2 and 3.
that is, if light 2 and light 3 were already on, before the sensor detects movement (motion violated) they remain on, otherwise they are turned off.
5. New violation detected by Motion sensor recounts the time and rechecks.

 

thanks,

 

Please login or register to see this image.

/monthly_2021_07/image.png.96be95e630dbb2441dcf0243b78472c4.png" />

 

 

 

 

  • 0
Posted (edited)

You have two motion sensors, how does this line looks in your code?

 

Please login or register to see this code.

 

Or can you share the code you are actually using? 

 

 

 

Edited by SmartHomeEddy

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