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


jgab

HC3 Scenes - schedule actions on times

Recommended Posts

Posted (edited)

When doing a scene on the HC3 there is the option to schedule invocations of the scene using the conditions sections and the 'cron' property.

Please login or register to see this code.

The above condition will trigger the scene every minute.

 

There are possibilities to be more specific and only trigger every minute on weekends with the value {"*", "*", "*", "*", "6,7", "*"}. etc.. 

It's also possible to limit it between sunset and sunrise but then we need to make more elaborate conditions. If we want to cover many different times we either need to create a very long condition (with any) and in the scene test what time was triggered - or create many smaller scenes that may turn out difficult to maintain.

 

So, if you want to keep most of your time scheduling in one scene, one approach is to setup a trigger for every minute like the condition above - and then in the scene make tests if the time is right for your various actions

 

One approach to structure such as scene is like below. It relies on being triggered every minute - and calling a user provided function clock(....) with various "nice to have parameters" that can be easily tested against if the time is right.

Please login or register to see this code.

We can reason about time as a Lua string of format "HH:MM". We can test for equality and less than and greater than (be aware of times spanning midnight). We have also boosted the tonumber() function so that it converts a "HH:MM" string to it's value in seconds. That allows us to do some simple arithmetic like in the last example where we test if the time is 10min before sunrise and it's weekend.

Running a scene like this every minute will not take a huge toll on the HC3...

 

Anyway, this is a simple way to create a scheduler of actions using a scene - I'm sure there will be more to come...

Edited by jgab

Share this post


Link to post
Share on other sites

This is great! Thank you very much for sharing. 

Share this post


Link to post
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
Reply to this topic...

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