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

Scene programming based on time period


Question

Posted

Hi all !

I am trying to create a scene which I want to run only between a certain time of the day. For example, only notify me if there is motion activity on the rear of the house starting at 11pm to 6am everyday.

I've been trying to figure out how to do just that. Using the graphical block I can't seem to find a way to set a time "from" and "to" variable.

Any ideas on how to achieve this ? Or Do I have to use LUA ?

Thanks.

10 answers to this question

Recommended Posts

  • 0
Posted

I am afraid you need to use LUA. Just read current time and check in "if" instruction if it's period you want.

  • 0
Posted

If you wish to use the Block Scene Editor, then you can do this using variable.

You have two scenes setting and unsetting the variable.

Then use this as a condition in your motion scene.

Take a look at this example, it does exactly what you're looking for.

Please login or register to see this link.

The alternative way to do this is use a time scene to ARM and Disarm the motion sensor.

Hope that makes sense.

  • 0
  • Inquirer
  • Posted

    Thank you so very much especially to monions for that excellent vesternet article. I will try it out and test it. Cheers !

    • 0
    Posted

    Wow... Four active scenes to achieve this... This will put a huge load on your HC2 if you need to have just a few instances of this running! Here is a sample lua code which will do what you want:

    Please login or register to see this code.

    Replace "--do something" with the function you want.

    If you want it to send you a push message on your phone, then insert this code:

    Please login or register to see this code.

    Replace the [Phone id] with the ID number that the HC2 has assigned to your phone.

    If you want it to activate another scene from this script then you replace "--do something" with:

    Please login or register to see this code.

    This is a much sleaker piece of code than having four scenes.

    • 0
    Posted

    I fully agree that the LUA is a much neater solution and your's is pretty compact.

    The example we use is to show people how to do it in the scene editor, plus the HCL users who don't have the LUA option.

    We're going to create some LUA examples - I was looking at your Motion controlled lighting code - that's also very nice.

    • 0
  • Inquirer
  • Posted

    It looks like the LUA method certainly is easier and everything is one place. But to the LUA challenged user, the multiple scenes ideas are easier. Speaking of LUA, where can I get the LUA language and functional references to fibaro internal classes and functions ?

    • 0
    Posted
    It looks like the LUA method certainly is easier and everything is one place. But to the LUA challenged user, the multiple scenes ideas are easier. Speaking of LUA, where can I get the LUA language and functional references to fibaro internal classes and functions ?

    There is something in polish, but no proper english documentation for the fibaro classes.

    As to the Lua challenged user, I think it is just a question of taking an hour out to get a grip on the basics. I only started programming Lua about three months ago and have already gotten a real good grip on it. It is a far easier language to understand than for instance C++

    • 0
  • Inquirer
  • Posted

    Yes I agree. I have no problem with LUA as I used to do web programming and other OS X Development too but the lack of API (functional classes) in english from Fibaro is seriously not cool. They are neglecting their non polish customer base. Anyway I found it in google docs here

    Please login or register to see this link.

    The only reason why I wasn't getting to grips with LUA is because so far the graphical blocks seems to cater to my needs. I think it's high time to learn this now as the scenes gets a bit more complicated.

    Cheers guys !

    • 0
    Posted

    I wonder about some of the 'facts' that are written here.

    Is Lua faster , more secure and less of a burden on the HC2 than 'blocks' ?

    I don't think so.

    The HC2-code clearly has a block-to LUA-translator, which is demonstrated by the fact that every block-scene is immediately converted to a LUA-scene.

    So the LUA-scene resulting froml the block-diagram is what is used in the basic HC2-code.

    This means that there is no reason why a well-wriiten, 'block'-code would be better or worse than the equivalent LUA-code.

    Most of the time I write the basics of my scenes in 'block'-mode, then switch to LUA and make the necessary changes and add what is needed.

    As far as I know it is this final LUA-code which is then assembled into machine-code and executed by the HC2.

    So, no difference between LUA and 'blocks as blocks are translated into LUA and LUA assembled into machine code...

    As long as you make sure you don't have too many loops and do some basic housekeeping, like first checking of a device is really 'on' before telling it to switch off and so on, then there should be no important difference in performance.

    Following this strategy I have > 200 devices and > 200 scenes running for three months now without any problem.

    Correct me if my understanding is wrong ?

    • 0
    Posted
    I wonder about some of the 'facts' that are written here.

    Is Lua faster , more secure and less of a burden on the HC2 than 'blocks' ?

    I don't think so.

    The HC2-code clearly has a block-to LUA-translator, which is demonstrated by the fact that every block-scene is immediately converted to a LUA-scene.

    So the LUA-scene resulting froml the block-diagram is what is used in the basic HC2-code.

    This means that there is no reason why a well-wriiten, 'block'-code would be better or worse than the equivalent LUA-code.

    Most of the time I write the basics of my scenes in 'block'-mode, then switch to LUA and make the necessary changes and add what is needed.

    As far as I know it is this final LUA-code which is then assembled into machine-code and executed by the HC2.

    So, no difference between LUA and 'blocks as blocks are translated into LUA and LUA assembled into machine code...

    As long as you make sure you don't have too many loops and do some basic housekeeping, like first checking of a device is really 'on' before telling it to switch off and so on, then there should be no important difference in performance.

    Following this strategy I have > 200 devices and > 200 scenes running for three months now without any problem.

    Correct me if my understanding is wrong ?

    The translation process is quite ressource heavy, and your scenes will be translated at each start. Not once. As I gather, the block code translates into Lua which is then assembled into machine code, then on scene termination the translation will be lost and then retranslated at next instance.

    Also, the block code is by no means optimal, so it will include a lot of fluff into the code. And, you have no way of controlling your loops. If you know lua, you shouldn't use the graphical block builder. Especially if you need 4 scenes to do something I can do with five lines of code. Four scenes equals four instances of lua running simultaneously. As I read what you do, you just use the graphical blocks for templates and then build your code on that in Lua, so I guess that is because you have experienced that the graphical block builder isn't producing the most optimal code. So by that statement and the fact that you mention proper system housekeeping also just underlines the fact that graphic code building is going to affect performance compared to a Lua scene.

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