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

Schedule-based rule not working


Question

Posted

I have the following code, through which I'm trying to make a LED-strip in the kitchen switch on and off based on a schedule.

In this case it should switch on every Saturday and Sunday at 7h30 and go through a series of colors based on timers. Since I want to be able to override it manually, this seemed the easiest solution to me.

Please login or register to see this code.

Initially this worked without having the second time-check in (8h), but since I wanted to prevent the rule from starting also when I restart HC2 during the middle of the day, I build in an extra check to make sure that the timer will only start if it's between 7h30 and 8h.

And after that, it's not working anymore. It always states the if-statement is not true, even if it should be true. What am I doing wrong here?

10 answers to this question

Recommended Posts

  • 0
Posted

It should be 07:30 and 08:00. (with the 0 in front) I guess.

  • 0
  • Inquirer
  • Posted

    Thanks you for you suggestion. I tried it just now, but it didn't change the result. For tidiness I kept it the way you stated.

    • 0
    Guest GG
    Posted

    wday 1 equals sunday

    wday 2 equals monday

    ...

    wday 6 equals friday

    wday 7 equals saturday

    As fas as I understand, if you want the scene to run all the time, you need a while-loop around everything with a sleep(60000) in the end. Otherwise the scene will run only once, in your case it will work only if you start it friday och sunday between 07:30 and 08:00

    Try this:

    Please login or register to see this code.

    • 0
    Posted

    This should do the trick:

    Please login or register to see this code.

    I miss the loop, so if you want to run it more then once you have to add something like "while true do".

    • 0
    Posted

    I do not have any RGB yet but Jompa68 tested for me for the LUA Scheduler. The call was setRGBColor but setColor may also work.

    Have a look in the code here

    Please login or register to see this link.

    • 0
    Guest GG
    Posted

    When writing lua-scenes, I sometimes make a temporary scene, to test my code.

    If you write this (one of your lines of code from above) in a scene and click run, you can see what the output becomes.

    Please login or register to see this code.

    In this case the output will be 730.

    For a programmer, this line of code is not optimal.

    In string.format "%02d" means that you will format an integer number and always get at least two digits in the output string. If the source is only one digit (i.e. 0 - 9) a zero will be added infront

    of the digit. This means 6 will become "06" and 12 will become "12".

    But in your case you input a string "07" to the format.string function which in turn tries to format an integer number (%d) into a string again. And last you convert the string to number again (tonumber). This makes the result become 730.

    It would be better, more clear what the code does to write

    Please login or register to see this code.

    in your case.

    Personally I would write it:

    Please login or register to see this code.

    And finally, your code will only be run once as you have no while loop. It will only work if you start it between 07:30 and 08:00 on saturdays or sundays.

    [ Added: 2013-10-27, 13:38 ]

    robmac

    As I see it, there is no setRGBColor action, see attached image.

    I'm using version 3.570.

    Please login or register to see this attachment.

    • 0
  • Inquirer
  • Posted

    Wow, very much appreciated guys, thanks! It's working now. Sorry to be such a noob at this, but I recently switched from Zipabox to Fibaro. Haven't regretted the switch at all, but the LUA-bit is still a bit of a challenge for me. Hoping to get some basic functions working with the help of this forum and then be able to help myself after that (and hopefully some new noobs to come after that

    Please login or register to see this image.

    /emoticons/default_wink.png" alt=";)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />).

    • 0
    Posted
    As I see it, there is no setRGBColor action, see attached image.

    I'm using version 3.570.

    Thanks for that will add setColor to the scheduler

    Save all those loops if you have a lot of timers needed.

    Do you know how the startProgram works?

    I have added setColor (was already there but translated)

    setW, setR, setB, setG

    Please can someone test as I have no RGB modules yet

    Please login or register to see this link.

    • 0
    Guest GG
    Posted
    Do you know how the startProgram works?

    Yes. There are a couple of predefined programs in the unit. To that you can add your own programs where you define a color and a duration and an optional transition time to the next color etc.

    This way you can build programs with up to 70 steps to produce your specific "color movie" to be played by the unit.

    As I understand it, these programs are downloaded into the unit and run from there. This way you can have very small durations for each step in the program (20ms) if you want.

    The first 5 programs are predefined, the last two I have made.

    Please login or register to see this code.

    will start program "Storm".

    Ulf

    Please login or register to see this attachment.

    • 0
    Posted

    Code:

    fibaro:call(1801, "startProgram", "2");

    Many thanks

    Have added startProgram to this version.

    Must get some RGB modules.

    Please login or register to see this link.

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