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

Motionsensor light on/dim/of + time of day + Lux SIMPLE LUA


Question

Posted

With help from Dale1985 iv got this LUA scene working. Iv added some small things to it.

This scene is simple, and for those that know LUA it's nothing new. But it might be good for some beginners like myself.

This scene will now turn on/dim/off lights when movement, but with different settings during different time of day, and also like in my case where i dont want it to go on/off if there is sunny and no need of light. Also added small time delay before it goes off.

I use this scene in my kitchen area by example.

It will need some global variables, feel free to set them as you like:

Time_of_Day

-Morning (iv set this to sunrise)

-Afternoon (after 12:00)

-Evening

-Night

Sunny_Cloudy

-Sunny (set if over 150lux then its sunny)

-Cloudy (set if under 150lux then cloudy)

You will have to add and change device id. iv written in start which one you need changing, but you need to keep looking for same number and change further down in code

Please login or register to see this code.

And here you have 1 scene for the "Sunny_Cloudy" global variable.

All you need is to make a global variable. Iv called this:

Sunny_Cloudy

-Sunny (in this one over 100lux is sunny, feel free to change)

-Cloudy (under 100lux is cloudy, feel free to change)

Please login or register to see this code.

4 answers to this question

Recommended Posts

  • 0
Posted

You've done things a bit too literally, so you need to remove the second properties instance (the part with autostart).

I've tried to clean up your code a bit

Please login or register to see this code.

I'm not entirely sure why you are doing the delay thing with the motion sensor before switching off. What is your idea behind that?

  • 0
  • Inquirer
  • Posted

    Thank you.

    The reason i have morning and afternoon the same way is mostly cause i might want to change it for later.

    And this:

    if fibaro:countScenes()>1 then

    So its good to add this to all scenes? also my light and heat scene by example?

    And also the

    --[[

    %% autostart

    %% properties

    4 value

    %% globals

    Time_of_Day

    --]]

    is only needed once even when you have several scenes in one?

    Again thank you!

    • 0
    Posted

    You should have the countScenes part in all your scenes, unless they should run multiple times on top of each others, which might be of some use in special cases.

    The properties part (the part with autostart) is only needed once. Even though you call it two scenes in one, it really just is one scene with two functions.

    You might also consider changing the way you control your light to using an array. Then you can simply have an array with the index "afternoon" and then the individual values for that scenario and then you only need one function to run that, instead of a series of if-then conditions for the individual scenarios. That will make expanding the number of scenarios a lot easier.

    • 0
  • Inquirer
  • Posted
    You should have the countScenes part in all your scenes, unless they should run multiple times on top of each others, which might be of some use in special cases.

    The properties part (the part with autostart) is only needed once. Even though you call it two scenes in one, it really just is one scene with two functions.

    You might also consider changing the way you control your light to using an array. Then you can simply have an array with the index "afternoon" and then the individual values for that scenario and then you only need one function to run that, instead of a series of if-then conditions for the individual scenarios. That will make expanding the number of scenarios a lot easier.

    Thank you.

    Im not totaly sure if i follow you on the last part. Can you post a code of yours where you use this for me to see, then maybe i understand better.

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" />

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