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

Devices not executing commands


Question

Posted

Dear community,

 

I have started building some basic lua scripts that turn on/off some lights in my home based on some criteria. What I noticed that a command like fibaro:call(6, "turnOff") is not guaranteed to turn off the device. This means that sometimes I enter my living room in the morning and notice that a light did not turn on or off. My question to the developers in this group is: do you recognize the fact that turnOn and turnOff sometimes do not execute and if so, how do you handle that? Do you embed your calls in a retry loop?

 

Harald

11 answers to this question

Recommended Posts

  • 0
Posted

Hi

Maybe the same reason.

Hcl 4.100

I have 6 Danfoss thermostats, which I control with block scenes.

If I do not put a delay (a minimum of eight seconds) on the scene, the changes will not be performed.

This also applies to almost all other devices.

The problem has been there in previous FW, disappeared and reappeared with 4.092 and 4.100

 

Also see:

Please login or register to see this link.

  • 0
Posted

I have scenes that control lighting in each room of our house (12 in total) and all working perfectly good. Even Philips HUE is not giving me any more problems. So, fibaro:call is working perfectly fine unless there is some other problems on the HC box? If scenes have loop it is good practice that loop is not repeated in less than 1 second, and then it is also good to kill all other instances and keep only one running. If you can post one of your scenes it would be much easier to diagnose problem.

 

  • 0
  • Inquirer
  • Posted (edited)

    Thanks for responding guys. The biggest problem I have is with the scene I trigger to put the lights on. As I use the lights to show we're at home even when we aren't, I want to be able to trust on the fact that they really get turned on.

     

    My scene to turn on is basically a slightly modified version of a block scene:

    Please login or register to see this code.

    The biggest trouble is with startScene(1), which is in fact calling a wrapper scene for a Hue bulb. It's code is:

    Please login or register to see this code.

    I think at least 10% of the times, the Hue in this scene does not turn on.

     

    Any suggestions are appreciated.

     

     

    Edited by Haraldinho
    • 0
    Posted

    Hi
    Have you tried to put delay, I would not be able to use my HCL if I do not put a delay of almost all my scenes.

     

     

    Please login or register to see this attachment.

    • 0
    Posted (edited)

    Well, first scene seems ok even approach is little bit problematic. It is time based scene looping all the time endlessly just to turn on lights at one moment of a day at sunset. If you use burglar alarm and alarm get breached then HC stops all running scenes that don't have ticked option "Do not allow alarm to stop scene while alarm is running". When alarm became safe again scenes will not start running again so lights will not be turned on or off until you either restart HC or save each scene. For that reason I would change that so scene is triggered by global variable named, for example, "Darkness". One scene that loops endlessly is enough to take care of this global variable to change its value and of course it must have ticked that option that it is not stopped by alarm. When global variable value is changed it will trigger scene that have it in header. Scene will then either turn on or turn off lights depending on the value of the global variable Darkness. Other reason to make it that way is to avoid too many scenes running all at the same time taking resources and making HC less responsive.

     

    For example I have 78 scenes on my HC2 but only ONE that is looping endlessly. All other scenes are triggered at the right moment, then they do their stuff and stop running until next trigger. This way load on CPU of my HC2 is minimized so it has enough resources to do other necessary stuff instead of running scenes that actually don't do anything.

     

    The other scene for HUE is then not necessary because that code can be easily copied to first scene but with small change. HUE lamps don't change color or saturation if they are not turned On. Also, if you change brightness from 0 to some value lamp will turn on so you don't need last line. So, code for lights would look something like this:

     

    Please login or register to see this code.

    And code for scene that will loop all the time and take care of some important time based global variables that then can be used to trigger scenes can be something like this:

    Please login or register to see this code.

    This is actually only part of my main scene but for start is good enough. Just add global variables and run this scene and you will have covered all events that are happening at some part of day with possibility to use also season time to change behavior of some events. Enjoy coding! :-)

     

    EDIT 03/12/16

     

    Corrected typo in above script and removed local variables "sunrise" and "sunset" that are not used in this version of script. This script does't have feature to allow you to change sunrisetime and sunsettime with VD for +/- 30 min.

    Edited by Sankotronic
    • 0
  • Inquirer
  • Posted

    Thanks @hTiger1, it might indeed be that this issue is related.

    @Sankotronic thanks for the script, it looks interesting. Will dive into it next week. The script I used is actually a block script that was converted to Lua by the HC. So the approach it takes on time comes from there. I like your approach, makes much sense to me. I think I will change my approach to this.

    • 0
    Posted

    Thank you, @Sankotronic!

     

    I Think I see a type in post #6, Main Scene "local timeOfDayMappin" should probably read "local timeOfDayMapping" (missing "g" in the end).

     

    However I can't get the code to work. I'm getting an error at line 126: attempt to concatenate global 'sunrise' (a nil value). I've put up a whole bunch of Global Variables trying a lot of timeofday-scripts here, but I've got none of the scripts to work. Could you perhaps give a list of your variables and their values? And where you put them (Variables: or Predefined variables:). Maybe a screenshot, too?

    • 0
    Posted

    Hi @robw

     

    You are right, there was typo in above script and I corrected it. Thank you for pointing out. I also removed local variables "sunrise" and "sunset" from line 126 that gave you so much problems and I apologize for that. This script does't have feature that allow you to change sunrise and sunset time by +/- 30 minutes so this variables are not needed. I hope that it will work now.

     

    • 0
    Posted

    Hi @Sankotronic

     

    Wow, you are a coding machine :) Thank you so much for helping out so quickly! I will test the script immediately. I have "MarginSunrise" and "MarginSunset" Global Variables set since before (with values from -30, -29...0...+29, +30 etc.). Perhaps changing the local variables "sunrise" and "sunset" to "MarginSunrise" and "MarginSunset" would have fixed it then (I have the Sunrise & Sunset VB)?

     

    Again, a big Thank You! Wish you a nice weekend!

    Cheers,

    Rob

    • 0
    Posted

    Thank you for kind words. I will soon publish here revamped "Main scene for time based events" and since you already added global variables you will be ready to upgrade without sweat.

     

    Enjoy coding and have a nice weekend!

     

    • 0
    Posted
    On ‎2016‎-‎12‎-‎03 at 10:22 AM, Sankotronic said:

    Thank you for kind words. I will soon publish here revamped "Main scene for time based events" and since you already added global variables you will be ready to upgrade without sweat.

     

    Enjoy coding and have a nice weekend!

     

     

    I've modded the script now (I just added some stuff), in order to try learning LUA programming. I'm getting a bit better, but I still have some lightyears of catching up to do :) Anyway, with the script, I could cut down on some scenes and that is good :)

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