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


  • 3

[SCENE] Main scene FTBE v1.3.4


Sankotronic

Question

Main scene FTBE v 1.3.4

 

Hello everyone!

 

NEW version is OUT!

 

More about scene and download you can find here:

 

WHAT'S NEW:

 

  • Main scene FTBE 1.3.4 - changed function for time of day calculation and added use of SleepState global to set time of day to morning when Awake  regardless of current time
  • Main scene FTBE 1.3.0 - cleaned some bugs, added some more checks to prevent scene from stop running due to errors. Optimized and compacted code, removed unnecessary comments. DemoMode only stops changing timers while user code and scheduled events will continue to execute. Darkness can now be changed by measured lux level or global variable that is set to lux value measured by light measuring devices placed outside. Scene is now running on setTimeout function instead on sleep for better timing and also aligns to 0 seconds or exact minute.
  • Sunrise & Sunset VD v1.4.0 - Modified main loop code to better handle global variables. Variables are now automatically repaired and are not reset to default settings after HC2 reboot. Added variable SunriseIcon to store VD icon ID and now when main icon for VD is set also all button icons are set automatically.
  • Home Status VD v1.1 - Added variable HomeStatIcon to store VD icon ID and now when main icon for VD is set also all button icons are set automatically. Added label that shows most important values on VD when closed.
  • Home Timers VD v1.1 - Added variable HomeTimersIcon to store VD icon ID and now when main icon for VD is set also all button icons are set automatically. Added label that shows most important values on VD when closed.

 

 

Please login or register to see this attachment.

 

 

NOTE - This version is compatible with previous versions so need to do any changes in your current code of other scenes and VD's.

 

REQUEST - If you like my work and found it useful please give me support by rating and writing short review. Thank you! :-)

 

PS

Dear friends from Slovakia you can find this scene and VD translated to your language here: 

Please login or register to see this link.

 

 

Edited by Sankotronic
Updated to new version
  • Like 17
  • Thanks 6
Link to comment
Share on other sites

Recommended Posts

  • 0
  • Inquirer
  • 17 minutes ago, maxxar said:

    Testing this nice Main scene for time based events control, but just ran into a question. 
    Is it possible to setup to run a scene every 5 min between a defined clock interval like 21:00 to 23:00?

     

    Hi @maxxar,

     

    Current version 1.2.5 cannot do that, but new version I'm now working on will have that ability for repeating scenes and VD's.

     

    Link to comment
    Share on other sites

    • 0
    2 minutes ago, Sankotronic said:

     

    Hi @maxxar,

     

    Current version 1.2.5 cannot do that, but new version I'm now working on will have that ability for repeating scenes and VD's.

     

    Thanks for reply @Sankotronic thats good news. Keep the up the good work! :-)

    Link to comment
    Share on other sites

    • 0

    Good evening

     

    I needed to have the Calendar Week so I have added a function doCalendarWeek() that writes the ISO 8601 Calendar week into a global variable called CalendarWeek.

     

    Here's the code:

     

    Please login or register to see this code.

    I am sure it could be done nicer ;-)

     

    To you who don't know ISO 8601 says the first week of a year is that week where the first Thursday is in. So it can be that 1. January is in week 53 (like 1.1.2010).

     

    Cheers

    Don

    Link to comment
    Share on other sites

    • 0
    On ‎04‎/‎04‎/‎2017 at 1:56 PM, AutoFrank said:

     

    Hi @lennypenny

     

    I posted this on another topic but I thunk it's good advice and worked well for me

     

    my mantra always is 'keep it simple' if possible...

     

    Thanks Frank.  I Will get round to it once I am back at home.  I did manage to get some Smart Lights going, using LUA to get my Hue's going.

    I do appreciate the work you and others put in here, in order to help others less knowledgeable.

     

    BTW.......  I do fancy your shack with all the "smarts"

    Link to comment
    Share on other sites

    • 0

    I have added a checker for BankHolidays. I am not happy yet with the flexibility to put the days into the array of BankHolidays to check.

    The function is called doBankHoliday()

     

    I will use this to check if the current day is a Saturday, Sunday or BankHoliday where I don't have to work ;-) i.e. do not shout the weather when entering the bathroom at 6 in the morning :D 

     

    At the moment it works like, define the fix Holidays for the whole country (here Switzerland), then define the fix holidays in a part of the country (here Province of Zurich), then calculate the variable holidays like easter, Pentecost, Ascension of Christ, etc. that apply for the whole country, additionally those who are variable only in a part (like Province of Zug - Corpus Christi, ImmaculateConception).

     

    Maybe there is a better way to put those arrays together.

     

    Basically it writes a 1 into the global Variable BankHoliday if today hit a day in the specified array. Otherwise a 0 is set.

     

    Let me know what you think ;-)

    Please login or register to see this code.

     

    Cheers Don

     

     

    Edited by DonQuichopp
    Link to comment
    Share on other sites

    • 0

    Hi,  I get the following debug message and I suspect I know why I am getting it

    Please login or register to see this attachment.

    The section I think is the cause:

    -- SCHEDULED SCENES SETUP ------------------------------------------------
    -- here you can setup scenes that will be executed at predefined time of
    -- day in format "00:00". You can set up more than one time during day.
    -- Also you can enter flag for each day of the week when scene will be
    -- executed or not. See more details bellow.
    local runSceneSchedName        = {152,155}
    -- enter scene IDs that will run at scheduled time separated by comma.
    local runSceneSchedID          = {sunsettime},{sunrisetime};
    -- enter at what time of day will scenes run separated by comma.
    -- You can define more than one time in format "00:00" for one scene
    -- or even use local or global variables like sunsettime or sunrisetime
    -- Example: {{"13:30", "19:20"}, {sunrisetime, "13:00", sunsettime}}
    -- in above example first scene will run at 13:30 and 19:20 while
    -- second scene will run at sunrisetime, 13:00 and at sunsettime


    -- IMPORTANT NOTE - if you use variable to set time then make sure that                     ****** I do not understand this section.  Perhaps much to do that English is not my first language.  Can someone perhaps POPULATE this area given all the other info I have inserted please. I usually understand better when I see exactly how my info is used to populate the syntax.  Thanks

     

    -- you add refreshing of value in function extraUserCodeFirst() like                      ******* I do not understand the use of this  "extraUserCodeFirst() "
    -- this for above example:
    -- runSceneSchedHour[2][1] = sunrisetime
    -- runSceneSchedHour[2][3] = sunsettime  where first square brackets
    -- [2] with number inside refers to second scene and second square
    -- brackets [1] with number inside refers to time in order which means
    -- sunrisetime is 1st time [1] for 2nd [2] scene and sunsettime is
    -- 3rd [3] time for 2nd [2] scene in a row added to the variable.
    local runSceneSchedHour        = {};
    -- enter here flag for each day of the week for scene to run at above
    -- scheduled time. if flag 1 the scene will run and if flag 0 then
    -- will not be run for that day. Remember, Sunday is first day of the
    -- week on HC2! Example for two scenes:
    -- {{1, 0, 0, 0, 0, 0, 0}, {0, 1, 1, 1, 1, 1, 0}} - in this example
    -- first scene will run only on Sunday, and second scene will run on
    -- weekdays byt not on weekends (Saturday and Sunday).
    local runSceneSchedWeek        = {1,1,1,1,1,1,1};
    -- enter here flag for sending push message when scene is executed
    -- 1 for sending message, 0 no messages
    local runSceneSchedPushFlag    = {1};
    -- enter here message content that will be sent to you when scene is
    -- executed. If above flag is 0 for any of the scenes then just put
    -- empty "" for it.
    local runSceneSchedPushMessage = {"STAIR LIGHTS ON"};
         

     

    Edited by lennypenny
    Link to comment
    Share on other sites

    • 0

    If you want to start the scene at a specific time you can enter the time in "" in the starttime variable.

     

    But if you want to use a Global variable like Sunrise, sunset, then you have to add this variable in the function extraUserCodeFirst().

     

    as the code follows a predefined path this function will be called first and the global variables are set.

     

    runSceneSchedHour[2][1] = sunrisetime

     

    this line defines to use whatever is saved in the variable sunrisetime for the second scene and the first time of that scene.

     

    i also think that you are using the sceneID wrongly, there you added the variables sunset,sunrise. Which are Strings in the Format "12:00" and expecting a number (ID)

     

    what are your requirements? Which scene do you want to start at which times?

     

     

    Link to comment
    Share on other sites

    • 0
    19 minutes ago, DonQuichopp said:

    what are your requirements? Which scene do you want to start at which times?

     

    Hi,  I have a scene which turns on lights going up my stairs.  This scene is to run at SUNSET and another Scene to turn it off at SUNRISE

    SUNSET = SCENE ID 152

    SUNRISE = SCENE ID 155

     

    I am just using these two for the moment in order to learn/test.  Once I understand it all, I will add the rest.  It is obvious to me that it is not the writeup at fault as others have understood the instructions, but rather my own problem

     

    Thanks a stack

     

     

    21 minutes ago, DonQuichopp said:

    then you have to add this variable in the function extraUserCodeFirst().

     

    Sorry, I can see where this is........

    -- EXTRA FUNCTION WHERE YOU CAN ADD YOUR CODE ----------------------------
    -- use this function to add code that will be executed before all other
    -- code in the loop
    function extraUserCodeFirst()
      -- if you use variable for scheduled execution of scene or VD then you
      -- need to add here equanation to get last value calcualted

     

    What is the syntax please?    function extraUserCodeFirst(???????????)

    Edited by lennypenny
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • On 4/11/2017 at 10:46 AM, lennypenny said:

    Hi,  I have a scene which turns on lights going up my stairs.  This scene is to run at SUNSET and another Scene to turn it off at SUNRISE

    SUNSET = SCENE ID 152

    SUNRISE = SCENE ID 155

     

    Hi @lennypenny,

     

    first you setup your scenes in Scheduled scenes setup:

    Please login or register to see this code.

    Then you find function extraUserCodeFirst() and add this two lines of code:

    Please login or register to see this code.

    If you want to use sunrise and sunset times with your margin settings set in Sunrise & Sunset VD then above is exactly that, if you want something to happen at exact time of sunrise and sunset then just use sunrise and sunset variables instead of sunrisetime and sunsettime.

     

    You can also turn on all debugging to check and get more info about your settings:

    Please login or register to see this code.

    And then you should see this in debugging window:

     

     

    Hope this helps!

    Enjoy! :-) 

     

    Edited by Sankotronic
    Attachment quota filled up / deleting older stuff sorry :-(
    Link to comment
    Share on other sites

    • 0
    1 hour ago, Sankotronic said:

    Hope this helps!

    Enjoy! :) 

     

    Hi Sankotronic,

     

    Thanks for your time in putting examples so easy that I really get what you are doing.

    This is my code:

    -- SCHEDULED SCENES SETUP ------------------------------------------------
    local runSceneSchedName = {"Sunset turn On", "Sunrise turn Off"}
    local runSceneSchedID = {152, 155};
    local runSceneSchedHour = {{"sunset"}, {"sunrise"}}; -- this values here can be anything with or without quotes!
    local runSceneSchedWeek = {{1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1}};
    local runSceneSchedPushFlag = {1, 0};
    local runSceneSchedPushMessage = {"TEST", ""};

     

    I have done exactly what you have advised but I get the following error:

    Please login or register to see this attachment.

     

    Any ideas please?

     

    Thanks in advance

    L

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 6 minutes ago, lennypenny said:

    -- SCHEDULED SCENES SETUP ------------------------------------------------
    local runSceneSchedName = {"Sunset turn On", "Sunrise turn Off"}
    local runSceneSchedID = {152, 155};
    local runSceneSchedHour = {{"sunset"}, {"sunrise"}}; -- this values here can be anything with or without quotes!
    local runSceneSchedWeek = {{1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1}};
    local runSceneSchedPushFlag = {1, 0};
    local runSceneSchedPushMessage = {"TEST", ""};

     

    I have done exactly what you have advised but I get the following error:

    Please login or register to see this attachment.

     

     

    Hi @lennypenny,

     

    SCHEDULED scene setup is working fine since there is no errors for it, but from debug window you have problem with settings for REPEATING scene what is not same. You just didn't setup one of the settings correctly. It is this settings for example:

    Please login or register to see this code.

     

     

    Link to comment
    Share on other sites

    • 0
    22 minutes ago, DonQuichopp said:

    Did you put:

     

    Please login or register to see this code.

     

    in extraUserCodeFirst()?

    Yes thanks for the hint though

    L

    18 minutes ago, Sankotronic said:

     

    SCHEDULED scene setup is working fine since there is no errors for it, but from debug window you have problem with settings for REPEATING scene what is not same. You just didn't setup one of the settings correctly. It is this settings for example

     

    Thanks Sanktronic,  this must feel to you like extracting teeth :roll:

     

     I now get another message no doubt because I messed up.....

    Please login or register to see this attachment.

    my code:  for one HUE Lamp to be turned on and off. It is the VD I got from you

    -- SCHEDULED VD SETUP ---------------------------------------------------
    -- here you can setup VDs that will be executed at predefined time of
    -- day in format "00:00". You can set up more than one time during day.
    -- Also you can enter flag for each day of the week when VD will be
    -- executed or not. See more details bellow.
    -- enter VD IDs that will run at scheduled time separated by comma.
    local runVDSchedID       = {283,283};
    -- enter here which button to press to execute command for each time that
    -- you enter bellow. Example for Sonos remote VD from Krikroff. If you set
    -- runVDSchedButton = {{"7", "9"}} and
    -- runVDSchedHour = {{"07:00", "23:00"}}
    -- Then button "2" (Play) will be pressed at 07:00 to start music and
    -- button "9" (Stop) will be pressed at 11:00 to stop music.
    local runVDSchedButton   = {{"1","1"}};
    -- enter at what time of day will VD button be pressed separated by comma.
    -- You can define more than one time in format "00:00" for one VD
    -- or even use local or global variables like sunsettime or sunrisetime
    -- Example: {{"13:30", "19:20"}, {sunrisetime, "13:00", sunsettime}}
    -- in above example first VD button will be pressed at 13:30 and 19:20
    -- while second VDs button will be pressed at sunrisetime, 13:00 and
    -- at sunsettime
    local runVDSchedHour     = {{"sunsettime","23:00"}};
    -- enter here flag for each day of the week for VD to press button
    -- at above scheduled time. if flag 1 the VD button will be pressed and
    -- if flag 0 then will not be pressed for that day. Remeber, Sunday is
    -- first day of the week on HC2! Example for two VDs:
    -- {{1, 0, 0, 0, 0, 0, 0}, {0, 1, 1, 1, 1, 1, 0}} - in this example
    -- first VDs button will be pressed only on Sunday, and second VDs
    -- button will be pressed on weekdays but not on weekends (Saturday
    -- and Sunday).
    local runVDSchedWeek     = {{1, 1, 1, 1, 1, 1, 1},{1,1,1,1,1,1,1}};
    -- enter here flag for sending push message when VD buttons is pressed
    -- 1 for sending message, 0 no messages
    local runVDSchedPushFlag = {1,1};
    -- enter here message content that will be sent to you when VD is
    -- executed. If above flag is 0 for any of the VDs then just put
    -- empty "" for it.
    local runVDSchedPushMessage = {{"ENTRANCE HUE LIGHT ON"},{"ENTRANCE HUE LIGHT OFF"}};


    Please bear with me.  once I have this right,  I can then get on by myself

     

    thanks again

    L

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 34 minutes ago, lennypenny said:

    Thanks Sanktronic,  this must feel to you like extracting teeth :roll:

     

     I now get another message no doubt because I messed up.....

    Please login or register to see this attachment.

     

    Hi @lennypenny,

     

    I'm not showing teeth :D, sorry if it sounded that way, on the contrary, I don't mind a million questions! So, here it is. You little bit mixed up braces {} and here is proper setup for Scheduled VD:

    Please login or register to see this code.

    And don't forget to add this line to function extraUserCodeFirst():

    Please login or register to see this code.

    I can see that you are setting up lights to be turned on or off at some predefined time using Main scene. Even this is at present moment acceptable for you, I'm almost 100% sure that when your home  automation mature you will definitely want more and then I challenge you try Very Smart Light™ scene. It has flexibility to control lights that has no match yet :) I will in near future post new version of Main scene and Very Smart Light™ scene with much simpler setup but much greater capabilities.

     

    Link to comment
    Share on other sites

    • 0
    46 minutes ago, Sankotronic said:

    I'm not showing teeth :D, sorry if it sounded that way, on the contrary,

    Hi Sankotronic,

    No I did not think you bared your teeth.  It is more that I sometimes feel a bit of a nuisance.  I will certainly have a look at VSL scene after this.  That is if this forum can cope with my muddles <grin>

    like his one:

    Please login or register to see this attachment.

     

    Please login or register to see this attachment.

     

    Thank you

    L

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 3 minutes ago, lennypenny said:

    Hi Sankotronic,

    No I did not think you bared your teeth.  It is more that I sometimes feel a bit of a nuisance.  I will certainly have a look at VSL scene after this.  That is if this forum can cope with my muddles <grin>

    like his one:

    Please login or register to see this attachment.

     

    Please login or register to see this attachment.

     

    Thank you

    L

     

    Just check previous posts since this is known issue, but also check if format of all times in Sunrise and Sunset VD are "00:00" or are missing minutes. If they are not presented in format "00:00" then you will have to pen VD for editing and press SAVE button so it can reset all variables to proper format. Also please don't press SAVE button in variable panel because this destroys values of variables.

    Link to comment
    Share on other sites

    • 0
    30 minutes ago, Sankotronic said:

    also check if format of all times in Sunrise and Sunset VD are "00:00"

     

    This has gone belly-up since I created it.  Now all sorted.  Thanks for your patience

     

    L

    Link to comment
    Share on other sites

    • 0

    Good Evening @Sankotronic, I don't know if you are still working on a new version of the MSFTBE.

     

    Maybe there is a way to add an option in REPEATING SCENES and VD's  like:

    Please login or register to see this code.

    To balance the load on the HC2 when all scene's and VD's are running at the same time.

    Like in the above example scene 1 runs every 2 minutes on the odd numbers(1,3,5,7, ect) scene 2 also on the odd minutes, scene 3 and 4 every minute  and the 5th scene on the even minutes(0,2,4,6 ect (I know 0 isn't even or odd :)))

     

    Jim

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 2 minutes ago, jimicr said:

    Good Evening @Sankotronic, I don't know if you are still working on a new version of the MSFTBE.

     

    Maybe there is a way to add an option in REPEATING SCENES and VD's  like:

    Please login or register to see this code.

    To balance the load on the HC2 when all scene's and VD's are running at the same time.

    Like in the above example scene 1 runs every 2 minutes on the odd numbers(1,3,5,7, ect) scene 2 also on the odd minutes, scene 3 and 4 every minute  and the 5th scene on the even minutes(0,2,4,6 ect (I know 0 isn't even or odd :)))

     

    Jim

     

    Hi @jimicr,

     

    I'm aware of the problem but still looking for the best solution. This with odd and even I don't really understand what you mean? Waiting for current time odd or even minute and then run scene or VD? But then it won't be really every 2 or 10 minutes, at least not every time since that Fibaro function for delay fibaro:sleep() doesn't really check current time, it just counts set number of milliseconds and then continues to run. Since code needs certain amount of time to execute, more is added more time it needs and then due to this fixed wait time it actually drifts slowly.

     

    So if I check if current time is odd or even it won't always be for same scene. I don't know if I'm clear enough? But don't worry, sometimes even I can't understand myself :D 

     

    Link to comment
    Share on other sites

    • 0
    Just now, Sankotronic said:

     

    Hi @jimicr,

     

    I'm aware of the problem but still looking for the best solution. This with odd and even I don't really understand what you mean? Waiting for current time odd or even minute and then run scene or VD? But then it won't be really every 2 or 10 minutes, at least not every time since that Fibaro function for delay fibaro:sleep() doesn't really check current time, it just counts set number of milliseconds and then continues to run. Since code needs certain amount of time to execute, more is added more time it needs and then due to this fixed wait time it actually drifts slowly.

     

    So if I check if current time is odd or even it won't always be for same scene. I don't know if I'm clear enough? But don't worry, sometimes even I can't understand myself :D 

     

     

    Thanks for your answer, my idea came while installing a few extra window sensors and banging my head against the windowsill really hard. I even have a bumb to show for it :)

     

    I understand your answer, like most of the time I was thinking out loud. the only way for this to work is adjusting the sleeptime to the number of actions the scene has to run. And that would be near impossible.

    The idea was to run some scenes and vd's on the odd minutes ,some on the even and the last few every minute.

     

    Jim

     

    Link to comment
    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
    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...