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


  • 2

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

  • 2
On 2/16/2020 at 11:01 AM, jgab said:

Poor man's os.time and fibaro.sleep, while we wait ??

Please login or register to see this code.

 

 

This was a half-joke but it actually works. If you set "Allow to restart a running scene" to 'no' (similar to "if fibaro:countScenes() > 1 then fibaro:abort() end") 

you can code like this (almost like in the old days).

Please login or register to see this code.

In practice the fibaro.sleep loop should be changed to a setTimeout loop to adopt the new coding style imposed, because sleep is a bit heavy on the system...  - but that's left as an exercise to the reader.

The condition sections to trigger on motion sensor with id 32 being breached should be:

Please login or register to see this code.

 

Edited by jgab
  • Thanks 1
Link to comment
Share on other sites

  • 1
58 minutes ago, jgab said:

In practice the fibaro.sleep loop should be changed to a setTimeout loop to adopt the new coding style imposed, because sleep is a bit heavy on the system...  - but that's left as an exercise to the reader.

 

Ok, to convert the sleep loop style we can have a function 

Please login or register to see this code.

This will call the <loop function> every X seconds until the function returns true, then it will call function <end function> (if given)

So the previous example becomes like below - and look and behold! we don't need neither os.time() nor fibaro.sleep() :-) 

Please login or register to see this code.

 

Edited by jgab
Link to comment
Share on other sites

  • 1
3 minutes ago, SmartHomeEddy said:

 

Thanks jgab. Thanks to this kind of ideas I can make my HC2 to HC3 working again. 

 

(btw my HC3 doesn't like the single quotes, I had to use double quotes)

Thanks, I fixed the single quotes in the original post. Sometimes when single quotes are copy and pasted they are transformed to `´quotes that don't work.

I like to use both double quotes and single quotes, trying to reserve single quotes for 'constant indicators' - but I guess I'm not always consequent.

Link to comment
Share on other sites

  • 1

Hi guys, I edited the scene and runs for me (see code below).

I added check against lux, manual override and check if light is on or off all ready.

It runs like a charm but I think the pro's here can clean the code to make it better.

Please login or register to see this code.

Conditions only check the motion sensor:

Please login or register to see this code.

 

maybe this helps someone.

 

Jim 

Edited by jimicr
Found error in code (stupid one)
  • Like 3
Link to comment
Share on other sites

  • 0

Current Lua doesn't support os.time() or os.date() function, therefore you cannot calculate any time slot. Should be fixed in next release.

Regarding block scene, I think this was not supported by HC2 also.

By the way meanwhile you can do it in QuickApp, os.time() and os.date() supported.

 

Edited by cag014
Link to comment
Share on other sites

  • 0
9 hours ago, 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.

 

I'm in the same boat. Seems we need to wait on a working firmware to get basic home automation working.

Any rumours when it can arrive? I saw on a Swedish forum that it might arrive 2 days ago, on Friday, but that did not happen.

Edited by robw
Link to comment
Share on other sites

  • 0
3 hours ago, robw said:

 

I'm in the same boat. Seems we need to wait on a working firmware to get basic home automation working.

Any rumours when it can arrive? I saw on a Swedish forum that it might arrive 2 days ago, on Friday, but that did not happen.

Poor man's os.time and fibaro.sleep, while we wait ??

Please login or register to see this code.

 

Edited by jgab
  • Like 2
Link to comment
Share on other sites

  • 0

i have it working on my hc3 with this rule.

if no motion is detected after safe for 3min it goes of if motion is detected it stays on


Please login or register to see this image.

/monthly_2020_02/image.png.e48a543f80597bf1a509c4be9256092b.png" />

  • Like 2
Link to comment
Share on other sites

  • 0
20 minutes ago, marius de jong said:

i have it working on my hc3 with this rule.

if no motion is detected after safe for 3min it goes of if motion is detected it stays on

No, it doesn't work as you think.

It will turn off light after 3 minutes always after sensor back to safe even if during this 3 minutes new motion detected.

You can test it very easy. After sensor back to safe wait for 2 minutes and then move again in front of sensor, the light will turn off after 1 minutes regardless last movement.

Edited by cag014
Link to comment
Share on other sites

  • 0
54 minutes ago, cag014 said:

No, it doesn't work as you think.

It will turn off light after 3 minutes always after sensor back to safe even if during this 3 minutes new motion detected.

You can test it very easy. After sensor back to safe wait for 2 minutes and then move again in front of sensor, the light will turn off after 1 minutes regardless last movement.

No it works as i said. But you made my doubt myself, so I tested it again.

I let the motion turn on the light waited 2minits after sensor went safe then made motion again and the light stays on for another 3minits so total it was on for 5min after first safe.


i got this set up for my toilet and my living and garden it works perfectly

Edited by marius de jong
Link to comment
Share on other sites

  • 0
43 minutes ago, marius de jong said:

No it works as i said. But you made my doubt myself, so I tested it again.

I let the motion turn on the light waited 2minits after sensor went safe then made motion again and the light stays on for another 3minits so total it was on for 5min after first safe.
i got this set up for my toilet and my living and garden it works perfectly

If you say so... but try to convert that to Lua and you'll see it runs in background for 3 minutes and then turns light off, while another instance runs for another 3 minutes. I've tested that as well.

The scene runs right after sensor went to safe and there is nothing that could stop it.

It is very interesting that we have different behavior on same solution!!??

Edited by cag014
Link to comment
Share on other sites

  • 0
16 minutes ago, cag014 said:

If you say so... but try to convert that to Lua and you'll see it runs in background for 3 minutes and then turns light off, while another instance runs for another 3 minutes. I've tested that as well.

The scene runs right after sensor went to safe and there is nothing that could stop it.

It is very interesting that we have different behavior on same solution!!??

I Will transfer it to lua and try. But in block it works. The only drawback is when I turn off the light manual it turns back on Strait away. So it always follows the timer

Edited by marius de jong
Link to comment
Share on other sites

  • 0
2 hours ago, jgab said:

Poor man's os.time and fibaro.sleep, while we wait ??

Please login or register to see this code.

 

Thank you, jgab! :)

 

Link to comment
Share on other sites

  • 0
21 minutes ago, marius de jong said:

I Will transfer it to lua and try. But in block it works. The only drawback is when I turn off the light manual it turns back on Strait away. So it always follows the timer

What???

Could you post block scene that turns your light ON? Looks like this is the problem, it shouldn't turn light ON if you turn it Off manually until motion detected. In addition it probably turns light ON even it if turns Off automatically and that's the reason why you think the delay is works.

Edited by cag014
Link to comment
Share on other sites

  • 0
15 hours ago, 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.

I don't think you are using the toilet pir for alarm systems so:

set in the pir save time to 3 min (or whatever you like)

scenes will be

if pir break, light on

if pir save light off

 

 

 

Link to comment
Share on other sites

  • 0
14 minutes ago, cag014 said:

What???

Could you post block scene that turns your light ON? Looks like this is the problem, it shouldn't turn light ON if you turn it Off manually until motion detected.

here it is.

but i now understand it its my toilet light so if i turn it off manual their is movement in the 1x1m3 room ?

 

Please login or register to see this image.

/monthly_2020_02/image.png.fdc61fc77ab56349e4ee2499199669c4.png" />

 

And i converted the off scene in lua it also works as a lua scene but in the debug i get error 2x

Please login or register to see this attachment.

Link to comment
Share on other sites

  • 0

So as you can see it waits for 3 minutes and turns lights OFF... nothing could stop it and for sure not additional movement.

As I mentioned, probably your block scene that turns lights On is the cause which turns lights On even when you turns them off.

Very interesting... could you please post your block scene that turns lights ON?

Link to comment
Share on other sites

  • 0

@jgab small observation:

Are you sure fibaro.debug("message") works? It prints "nil".

It should be fibaro.debug("tag","message") or print("message").

Or it has been redefined?

Edited by cag014
Link to comment
Share on other sites

  • 0
2 minutes ago, cag014 said:

@jgab small observation:

Are you sure fibaro.debug("message") works? It prints "nil".

It should be fibaro.debug("tag","message") or print("message").

It was a rewrite of the original example where I have 

Please login or register to see this code.

:-)

When we can use the tag for something I will revert :-) Now every HC2 coder including myself forgets the tag...

 

 

Edited by jgab
Link to comment
Share on other sites

  • 0
2 minutes ago, jgab said:

It was a rewrite of the original example where I have 

Please login or register to see this code.

:-)

When we can use the tag for something I will revert :-) Now every HC2 coder including myself forgets the tag...

 

 

Absolutely, happens to me all the time.

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