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

@SmartHomeEddy i managed to plug in the new code this morning and have been testing a bit throughout the day - i'm still seeing the error though, but haven't double, double checked i haven't copied it wrong or something. Will check more tomorrow.

 

i'm not sure how to debug on HC3, do i have to turn something on or go somewhere to see what its doing in the background?

Link to comment
Share on other sites

  • 0

You alreay saw the debug screen. 
 

You can use the debug screen by clicking the upper icon on the left bottum of your screen. 
 

 

 

Please login or register to see this attachment.

 

 

To use it full screen, push the icon on the right bottum. 

 

Please login or register to see this attachment.


 

I think the error has to do with the list of two or more lights. I have the same source running (but with only one light). I will keep an eye on it. 

 

BTW this error shows also when the scene is forced to stop

 


 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0

@SmartHomeEddy thanks for all your help, I've plugged in the code and tested the behaviour today (thanks for the debug tips too that was much better switching to full screen). Seems to be working ok but still see that blank error popping up now and again. 

 

I reduced the light level in the end a bit more to 200 lux, these lights are in the kitchen which we typically have on in the daytime too up to a certain point. I also switched the timing as well after you explained the logic more 15*60 etc... :)

 

What effect would i get adding local luxmin to the Actions section as well? Also could i add a Variable to the Declarations section (i have a night and day version), how would that look like?

Link to comment
Share on other sites

  • 0

In the daytime, your lights must go on after motion and only if lux is below a certain level?

 

And in the nighttime, what should it do, always on between specific hours? 
 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0

I’m thinking for a differnt room now but starting with the same base code, but this time the motion would only trigger 

 in night time. In daytime nothing happens. I have the variable already for daytime and nighttime already setup In case that’s good to use

 

I have the kitchen motion and lux below certain value all the time which is perfect.

 

Link to comment
Share on other sites

  • 0

I use copies of the scene for different rooms. That way I can tune the lux and maxTime easily. 
 

I have changed the code to make it more flexible, for instance, I use in my garage two motion sensors. 
 

In the declarations there are also time option like “sunrise” and “sunset”. If you add a block scene (and later disable it to keep it for future experiments) you can experiment with that condition and convert it to Lua to see how it looks like with all the {} and or constructions. 
 

In your case, copy your first scene to a new one, change the declaration between sunset and sunrise (is a condition not the trigger) and motion (as trigger) at night will turn on the light and the light stays on during motion. You don’t need the lux in the declaration as condition. 

 

 


 

Please login or register to see this code.

 

 


 

 

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

  • 0

@SmartHomeEddy - thanks for all your top help, i haven't cleaned up the code yet like you shared in your previous version but will get to it. Trying to use what you shared  @BusterB1959, having differnt dim levels for differnt times of the day. However getting an error, i'm sure its something simple - [ERROR] [SCENE59]: (load):43: 'end' expected (to close 'for' at line 16) near - any ideas?

 

It would actually be quite cool to use a a Global Variable i have setup call DayNight, instead of specific times, if thats possible?

 

Please login or register to see this code.

 

Link to comment
Share on other sites

  • 0

Think you just need another end on line 24 to close the for loop. If you step your code in for each fir, if, while etc you will see this. 

 

Link to comment
Share on other sites

  • 0

@BusterB1959 - thanks yep seems to have fixed it, i'll tidy it up a bit :) Thanks fo sharing

 

Do you think it's possible to use a Global Variable here instead of setting a specific times? 

Link to comment
Share on other sites

  • 0

These kind of scenes, turn off after x seconds tends to become more and more complex as more special conditions are added...

 

Here is an alternative way of coding these kinds of scenes. (Disclaimer: I do run the QuickApp, but have not tested the examples in this post)

First, there is a useful QuickApp here

 

It's a QuickApp that pretends to be a binary sensor.

It is configured with 2 quickAppVariables

  • "devices" that is a list of device IDs to watch, Ex. "21 214 155"
  • "delay" that is the delay in seconds until the sensors should be safe.

The QuickApp was created to allows us to create hierarchical sensors to watch the whole house but in this example it's enough to create one for a single room

If like in @SmartHomeEddy's example we configure the sensor with two lights and 900s (15min) delay until safe

  • "devices" = "219 228"
  • "delay" = "900"

Now we have a sensor that makes our job easy, assume that our new QA has the deviceID 410

 

Our scene must have a condition to trigger on device 410 having "anyValue" so our scenes gets triggered on any change of device 410

 

The action part becomes trivial. No more counting down as device 410 does that work for us.

Please login or register to see this code.

Having a simple logic allows us to add more complex tests easily.

Here we spend time on calculate the average lux and using it as a gatekeeper

Please login or register to see this code.

or have different dimValues for lights at specific times... Here we spend time on a flexible

Please login or register to see this link.

that can take sunset/sunrise and global variable values.

Please login or register to see this code.

We create an extra sensor for each room (the combined sensor QA) and it can seem superfluous, but it makes our scenes so much simpler. We can also combine these sensors to watch floorplans and the whole house easily.

One could also imagine doing similar things for multilevelSensors, ex. the lux sensors here to have a combined sensor that keeps the average of its sub sensors (or have the calculation algorithm choosable with a button - average, median, max, min etc)

A combined binary switch could set dimmers to appropriate values depending on time of day - this making the last scene as simple as the first scene.

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

  • 0

@jgab thanks this is really useful and i can see how it would be more efficient. I've looked in your QA thread a few times and although has loads of clear instructions, I'm a newbie and couldn't work out where to start.

 

I can see how to add a blank QuickApp from the "Add device" menu, and i maybe understand the scene options above - but i'm not clear how to bring that all together.

 

If there are any "getting started" instructions you could point me at, i could have a go trying to set one up?

Link to comment
Share on other sites

  • 0

I would be also greatful if someone would describe it in a "step-by-step" way... 

  • Like 1
Link to comment
Share on other sites

  • 0
1 hour ago, theuksbest said:

@jgab thanks this is really useful and i can see how it would be more efficient. I've looked in your QA thread a few times and although has loads of clear instructions, I'm a newbie and couldn't work out where to start.

 

I can see how to add a blank QuickApp from the "Add device" menu, and i maybe understand the scene options above - but i'm not clear how to bring that all together.

 

If there are any "getting started" instructions you could point me at, i could have a go trying to set one up?

 

This thread was a about a Scene and I guess they are supposed to be a bit "easier" to develop with "conditions" and all... however, they can also become very complex - and my example was a way to make it easier to cope with scenes that handle these kind of "do something after sensors been safe for X s". 

But tutorials are always good - is it Scenes, QuickApps, or Lua and Fibaro's APIs in general? or all three? and if so in what order? 

Link to comment
Share on other sites

  • 0

@jgab I could definitely see how your suggestion would make it easier to build in all the extra conditions, happy to give it a go!

 

For me I think my knowledge gap is probably a bit of all three; but guidance on starting out adding and configuring a QuickApp with Lua and API calls from scratch is what's missing mainly for me right now. I feel i could probably drop in your codes to a Scene ok, i managed to pull everyones code into the one i posted above for example (thanks to  @SmartHomeEddy & @BusterB1959 ). I couldn't work out how to add the QuickApp you suggested above though and add the "devices" and "delays" to it.

 

Link to comment
Share on other sites

  • 0
5 hours ago, jgab said:

Here is an alternative way of coding these kinds of scenes. (Disclaimer: I do run the QuickApp, but have not tested the examples in this post)


I am gonna take a look. I already saved @jgab your generic scene, to manage all light automation in that one scene. Now with the quickapp solution for motion it will be complete. I will study the info. 

Link to comment
Share on other sites

  • 0

@jgab I spent the best part of an hour studying the QA thread but not managed to interpret much - i'm limited to copy and pasting really with limited interpretation of the code, it's just the extent of my technical ability i'm afraid.

 

Is it not possible to package up into Solutions your QuickApps and let users download them, maybe you can already do that?

 

 

Link to comment
Share on other sites

  • 0
7 minutes ago, theuksbest said:

@jgab I spent the best part of an hour studying the QA thread but not managed to interpret much - i'm limited to copy and pasting really with limited interpretation of the code, it's just the extent of my technical ability i'm afraid.

 

Is it not possible to package up into Solutions your QuickApps and let users download them, maybe you can already do that?

 

 

My intention was not that you should need to do any QA coding.

In the post I refer to  there is a link to the QA file: 

Please login or register to see this link.

In the HC3 manual there is a section how to install QAs from file (Upload File): 

Please login or register to see this link.

When the QA is installed on your HC3 you set the 2 quickAppVariables that are mentioned in the post. What sensors to watch and what "delay time" to use.

....setting quickAppVariables is done in the "Variables" tab for the device. (Don't forget to press the "Save" button after you added/set the variables)

Then you refer to that device from your block scene or Lua scene.

 

 

 

 

Link to comment
Share on other sites

  • 0

@jgab brilliant, that was much easier. Thank you, really appreciate taking me through it!

 

Before i expand on that, is it worth starting with a multi-level switch then since maybe it would be also better to have the Lux level set as part of the sensor as you mentioned above? is there a template for that, or can i upgrade this one i've just added?

 

Also my next objective would be to use a Global Variable i have for Night/Morning/Day/Evening, to determine the dim level in the scene rather than specific times

Link to comment
Share on other sites

  • 0
47 minutes ago, theuksbest said:

Also my next objective would be to use a Global Variable i have for Night/Morning/Day/Evening, to determine the dim level in the scene rather than specific times

Hi @theuksbest,

I'm using Global you've mentioned, but also variables to determine starting time of those day parts :-D

 

Edited by Bodyart
Link to comment
Share on other sites

  • 0
48 minutes ago, theuksbest said:

@jgab brilliant, that was much easier. Thank you, really appreciate taking me through it!

 

Before i expand on that, is it worth starting with a multi-level switch then since maybe it would be also better to have the Lux level set as part of the sensor as you mentioned above? is there a template for that, or can i upgrade this one i've just added?

 

Also my next objective would be to use a Global Variable i have for Night/Morning/Day/Evening, to determine the dim level in the scene rather than specific times

The QA I included is only a binary sensor that can aggregate other sensors.

If you saw my second example in the earlier post I added a loop in the scene that checked the lux value before turning on the lamps. (calculated the average for the sensors)

In my third example in the same post I had a table that said what value to set a dimmable light to depending on time of day. That table could use sunset or global variables to define the times.

You could combine them in the same scene.

Please login or register to see this code.

This will substitute '$Night' with whatever string is in the fibaro global 'Night'. 

It will also substitute 'sunrise' with todays sunrise. Assume 'Night' is "23:45" and 'sunrise' is "06:00". It will then become

Please login or register to see this code.

..and it allows for +/' calculations so it become

Please login or register to see this code.

and the dim value for the light will be set to 25 between 23:55 and 05:50

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