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
  • 12 hours ago, diStefano said:

    I´m going to start using this scene together with the Sunrise/sunset VD and the Very Smart Light scene.
    I have a HC2 as master controller and HC Lite as a slave controller, do I install the scenes and VD on both controllers?

     

    Hi @diStefano,

     

    Since VD and scene are written in LUA language you can install them only on HC2 but I believe that that will be sufficient to control complete system since any device included on HCL should be also available on master HC2.

     

    Link to comment
    Share on other sites

    • 0
    2 minutes ago, Sankotronic said:

    Hi @Figlio and welcome to Fibaro forum!

     

    Did you manage to solve your problem?

    Hi @Sankotronic,

     

    Yes I did manage. It took me some time but figured it out. I was reading your instructions and kept on being stuck after pasting the scene and debugging. It would give me the debug as you present in the first post. However, i figured that not all variables were being created by the VD. Since I'm a newbie both on the forum as in programming fibaro i didn't notice this before. Anyway, its working now as expected. Now its time to start using these variables in scenes.

     

    Great work! and easy to set up as well once you understand the basics. My search did learn me lots though....

     

    I will also give your other scenes and VDs a go.

     

    Thanks again!

    Link to comment
    Share on other sites

    • 0

    hello. ive installed the script and "think"ive added all the variables needed..but.... it doesnt work.you cant change day on the VD and doesnt seem to auto update any of the variables. and i get this debug.

    thanks in advance for any herlp or pointers

    ed

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hi @Edb,

     

    Did you first install Sunrise & sunset VD? Did you use Save button in variable panel after Sunrise & Sunset VD was installed? If you did use Save button then open to edit Sunrise & Sunset VD again and press Save button to correct values of variables generated by that VD. As I mentioned before, if Main scene is not working on the first run then it is always due to missing global variable or pressing save button in variable panel. There are two other VDs Home status and Timers that can be used to change values of global variables for testing purpose.

     

    Link to comment
    Share on other sites

    • 0

    @Sankotronic great bit of work.. I just took the plunge to get this going but am getting the following error. I have gone thru and installed the 3 VD's and set them up so to show the correct values read from Variables. What can you recommend I look at?

     

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 7 hours ago, rajp said:

    @Sankotronic great bit of work.. I just took the plunge to get this going but am getting the following error. I have gone thru and installed the 3 VD's and set them up so to show the correct values read from Variables. What can you recommend I look at?

     

    Please login or register to see this attachment.

    Hi @rajp,

     

    there was similar question already in some of previous posts so please check. Also see my previous post.

    Link to comment
    Share on other sites

    • 0
    2 hours ago, Sankotronic said:

    Hi @rajp,

     

    there was similar question already in some of previous posts so please check. Also see my previous post.

    Thanks for that.. looked back and I was missing the Darkness Global Variable.. once setup, it was all running..

    Link to comment
    Share on other sites

    • 0
    On 2/25/2017 at 6:45 AM, Sankotronic said:

    Hi @Edb,

     

    Did you first install Sunrise & sunset VD? Did you use Save button in variable panel after Sunrise & Sunset VD was installed? If you did use Save button then open to edit Sunrise & Sunset VD again and press Save button to correct values of variables generated by that VD. As I mentioned before, if Main scene is not working on the first run then it is always due to missing global variable or pressing save button in variable panel. There are two other VDs Home status and Timers that can be used to change values of global variables for testing purpose.

     

    thanks for the advice. ill check and see.

    Link to comment
    Share on other sites

    • 0

    Hi Sankotronic,

     

    I am struggling with repeating VD setup, I have followed your instruction and am receiving the below error.

     

    [DEBUG] 21:07:05: Repeating VD setup error! Missing argument. Please check. Scene is stopped!

     

    I have read every post in this topic and have been un able to find the answer.

     

    Below is my code, can you tell me what I'm doing wrong?

     

    local runVDRepeatID          = {114};
    -- enter here which button to press to execute command
    local runVDRepeatButton      = {"3"};
    -- enter at which interval time in minutes will VD run separated by comma.
    local runVDRepeatTime        = {1};
    -- enter here flag for sending push message when VD is executed 1 for 
    -- sending message, 0 no messages
    local runVDRepeatPushFlag    = {1};
    -- enter here message content that will be sent to you when VD is
    -- executed. If above flag is 0 for any of the VD then just put
    -- empty "" for it.
    local runVDRepeatPushMessage = {"test"};
    -- for each VD enter variable with name "count" (can be all same name)
    -- separated by comma. This is used to count interval at which VD will
    -- be executed and is neccessary for proper execution!
    local runVDRepeatCount       = {count};
    -- enter here "Yes" for each VD if you want them to run immediatelly when
    -- this scene starts running after reboot or saving or enter no if you
    -- want VD to run after defined interval
    local runVDAtStart           = {"yes"};

     

    are you able to identify my issue? I have been looking at this for 2 days now.....

     

    Thanks in advance ;-)

     

     

     

     
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 9 hours ago, Robert Folbigg said:

    Hi Sankotronic,

     

    I am struggling with repeating VD setup, I have followed your instruction and am receiving the below error.

     

    [DEBUG] 21:07:05: Repeating VD setup error! Missing argument. Please check. Scene is stopped!

     

    I have read every post in this topic and have been un able to find the answer.

     

    Hi @Robert Folbigg,

     

    I tested your settings above and have no issues at all. The only thing is that runVDAtStart should be set to "Yes" with capital letter, but that is not reason for above error. Are you using latest version of Main scene v1.2.5?

    Link to comment
    Share on other sites

    • 0

    Dobar dan Zoran,

     

    I'm struggling a bit with this scene, because my week doesn't start on Sunday, but on Monday, so I changed the code like this:

     

    ----------------------------------

    local weekDay   = "WeekDay";
    local weekDayMapping      = {Monday    ="Maandag",
                                                   Tuesday   ="Dinsdag",
                                                   Wednesday ="Woensdag",
                                                   Thursday  ="Donderdag",
                                                   Friday    ="Vrijdag",
                                                  Saturday  ="Zaterdag",
                                                  Sunday    ="Zondag" };
    -- enter week days in your language and mapped in previous variable
    local weekDayMap          = {"Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag" };
    -----------------------------

    The problem is that the scene is showing one day early i.e. today on Saturday it shows Sunday. Can you see what am i doing wrong?

     

    Thanks in advance,

    Peter

    Link to comment
    Share on other sites

    • 0
    Guest aj84

    Like Clowg, I too am having the same issues with the Sunset VD not updating the Weekday, Month, Season, Darkness etc in the Timers VD.

     

    For a while I've ignored this as what I was using it for it worked but now the time has come to use it so I thought I'd investigate and ask the question on why it does not work.

     

    The buttons manually work fine in the Timers VD (so I can set manually the day but tomorrow, I'll have to update it )

     

    I thought maybe I missed some steps so I deleted every variable, scene and VD relating to this thread and started again.

     

    My steps were :

    1. Import Sunrise & Sunset VD

    1a: This updated itself and the variables as expected with all of the values being successful.

    2. Added TimeOfDay, WeekDay, Month, SeasonState and SleepState in predefined (lower)

    3. Added Darkness in global (upper)

    4. Added DemoMode in predefined (lower)

    5. Copy/Paste LUA script Main scene for time based events v1.2.5.lua into LUA scene creator and hit save.

    Log: [DEBUG] 20:36:23: Main scene for time events version 1.2.5 - © 2016 Sankotronic
    [DEBUG] 20:36:23: line 454: attempt to perform arithmetic on local 'diffMinute' (a nil value)

     

    So what the heck have I missed?

    I've not modified any of the global variables and hit save.  My current values are:

    Darkness: 1, DayTime:7, Lat/Long: (with values that are correct).

    MarginBlinds: 5, MarginDay: 2, MarginNight: 3, MarginSunrise: 0, MarginSunset: 0, NightTime: 21, OpenBlindTime: 10, SunriseTime: 0551, SunsetTime: 1824

     

    Predefined:

    DemoMode: No, Month: January, SeasonState: Winter, SleepState: Awake, TimeOfDay: Night, WeekDay: Sunday

     

    Thanks :)

     

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 1 hour ago, Bodyart said:

    Dobar dan Zoran,

     

    I'm struggling a bit with this scene, because my week doesn't start on Sunday, but on Monday, so I changed the code like this:

     

    ----------------------------------

    local weekDay   = "WeekDay";
    local weekDayMapping      = {Monday    ="Maandag",
                                                   Tuesday   ="Dinsdag",
                                                   Wednesday ="Woensdag",
                                                   Thursday  ="Donderdag",
                                                   Friday    ="Vrijdag",
                                                  Saturday  ="Zaterdag",
                                                  Sunday    ="Zondag" };
    -- enter week days in your language and mapped in previous variable
    local weekDayMap          = {"Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag" };
    -----------------------------

    The problem is that the scene is showing one day early i.e. today on Saturday it shows Sunday. Can you see what am i doing wrong?

     

    Thanks in advance,

    Peter

     

    Hi @Bodyart,

     

    No matter which language and location you set, for HC2 Sunday is always first day of the week so you shouldn't change sequence of days in the code of Main scene. If you think better it really doesn't matter what day of the week is first in code since it is not shown anywhere. This is important only if you want to print out month, but it can be again set in code, just not this one. So, for proper functioning of the scene you should set the sequence back as it was.

     

     

    14 minutes ago, aj84 said:

    So what the heck have I missed?

    I've not modified any of the global variables and hit save.  My current values are:

    Darkness: 1, DayTime:7, Lat/Long: (with values that are correct).

    MarginBlinds: 5, MarginDay: 2, MarginNight: 3, MarginSunrise: 0, MarginSunset: 0, NightTime: 21, OpenBlindTime: 10, SunriseTime: 0551, SunsetTime: 1824

     

    Predefined:

    DemoMode: No, Month: January, SeasonState: Winter, SleepState: Awake, TimeOfDay: Night, WeekDay: Sunday

     

    Thanks :)

     

     

    Hi @aj84,

     

    Can you please post here screenshot of Sunrise & Sunset VD please? All those Margin variables except MarginSunrise and MarginSunset should be in format "00:00" same as SunriseTime and SunsetTime. If they are not, then they are corrupted by you pressing SAVE button in variable panel.

     

    To correct them you need to open Sunrise & Sunset VD for editing and then click on SAVE button. This will correct all variables and set them to default values. After that you can open VD and set your times accordingly.

    Link to comment
    Share on other sites

    • 0
    Guest aj84

    Thanks for the quick reply - Sorry that was my mistake - I had typed out the time and missed the :

    It should read 18:24 and 05:51.  The VD also states this (I can post a screenshot if required)

     

    The issue though is not the sunrise/sunset VD but more the timers one which seems to need a manual change everytime a day/month/state changes which I believe should be controlled by sunrise/set?

     

     

    Please ignore - either a moment of stupidity or it sorted itself out but I hit the Play button for the scene again and its updated it and is now showing like it's running

    1

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 1 hour ago, aj84 said:

    Thanks for the quick reply - Sorry that was my mistake - I had typed out the time and missed the :

    It should read 18:24 and 05:51.  The VD also states this (I can post a screenshot if required)

     

    The issue though is not the sunrise/sunset VD but more the timers one which seems to need a manual change everytime a day/month/state changes which I believe should be controlled by sunrise/set?

     

     

     

    Hi @aj84,

     

    that error is pointing to code line where is function that calculate times what leads us to conclusion that some of those margin times are missing minutes (corrupted)! So, Yes, please check again. Times on Sunrise & Sunset VD should look like this:

     

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    Hi @Sankotronic,

     

    I'm having another issue with the scene. It's showing weird distance from home, whiule I'm sitting next to my HC2. Any help will be appreciated.

     

    Please login or register to see this attachment.

     

    When I add a second user (also me) the distance shown is 5949988.6158879 meters. I can't figure this out....

    Edited by Bodyart
    Added second user
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 35 minutes ago, Bodyart said:

    Hi @Sankotronic,

     

    I'm having another issue with the scene. It's showing weird distance from home, whiule I'm sitting next to my HC2. Any help will be appreciated.

     

    Please login or register to see this attachment.

     

    When I add a second user (also me) the distance shown is 5949988.6158879 meters. I can't figure this out....

     

    Hi @Bodyart,

     

    you need to turn on location services for Fibaro application on your mobile device. Also you need to go to Configuration on web GUI interface and select Access control and then for each user select How frequently GPS position from the user's iPhone (Android) should be collected. 5 minutes is recommended settings.

     

    After you do that you will have to wait for some time before position is shown.

    Link to comment
    Share on other sites

    • 0

    Hi @Sankotronic,

     

    I didn't like much the display of distance like the distance is: 12.12345678 meter, so I've made a very little modification of the function getUserPosition() to display the distance without decimals. Also to display in meters below 1000 and in Kilometers above 1000.

    Lines in red are inserted; line in blue is modified.

     

    function getUserPosition()
      if #userID > 0 then
        for i = 1, #userID do
          if(fibaro:getValue(userID, 'Location') == nil) then
            if gpsDebug then logbug("orange", "No GPS position for "..fibaro:getName(userID)) end;
          else  
            userlocation = fibaro:getValue(userID, 'Location');
            userdistance = tonumber(fibaro:calculateDistance(userlocation, homelocation));
            measure = "meter"
            if userdistance > 1000 then
               userdistance = userdistance/1000;
                 measure = ("Kilo"..measure)
            end
            userdistance = tonumber(string.format("%.0f", tostring(userdistance)));

            if gpsDebug then logbug("white", fibaro:getName(userID).."  distance from home is:: "..
                                    userdistance.." "..measure) end;

          end
        end
      end
    end

     

    May this be usefull a bit.

     

    Edited by Bodyart
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 1 hour ago, Bodyart said:

    Hi @Sankotronic,

     

    I didn't like much the display of distance like the distance is: 12.12345678 meter, so I've made a very little modification of the function getUserPosition() to display the distance without decimals. Also to display in meters below 1000 and in Kilometers above 1000.

    Lines in red are inserted; line in blue is modified.

    ....

    May this be usefull a bit.

     

     

    Hi @Bodyart,

     

    I give up on further coding of that part since Fibaro location service was and still is not so usable. When location services are turned on for Fibaro app it just drains battery and occasionally it jumps for more than 100 meters and that is not good. Thanks for this code and I can incorporate it in next release.

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