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

  • 1

@Sankotronic what part did i miss to setup if all my lights did turnOn at midnight? 

 

Sorry @Sankotronic, was not your scene. I did play around with my ACWUT scene yesterday evening and it still was active...

Edited by jompa68
Link to comment
Share on other sites

  • 0

I've done a basic first test of these scripts, and got this error in the Main Scene: "[DEBUG] line 424: bad argument #1 to 'sub' (string expected, got nil)"

 

The Changes in the Main Scene I've done is:

- Removed the line: local jT = json.decode(fibaro:getGlobalValue("HomeTable"))

- Changed weekDayMap and monthMap to my language names

- Changed the "Timers" VD Weekday and Month names accordingly to above

- Added all Global variables, and also the weekday and month names to my language so it corresponds to the VD and Main scene correctly.

 

As I'm trying to learn scripting, it's probably an error on my side, but hopefully someone here can help me pinpoint where my mistake can be.

Link to comment
Share on other sites

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

    I've done a basic first test of these scripts, and got this error in the Main Scene: "[DEBUG] line 424: bad argument #1 to 'sub' (string expected, got nil)"

     

    The Changes in the Main Scene I've done is:

    - Removed the line: local jT = json.decode(fibaro:getGlobalValue("HomeTable"))

    - Changed weekDayMap and monthMap to my language names

    - Changed the "Timers" VD Weekday and Month names accordingly to above

    - Added all Global variables, and also the weekday and month names to my language so it corresponds to the VD and Main scene correctly.

     

    As I'm trying to learn scripting, it's probably an error on my side, but hopefully someone here can help me pinpoint where my mistake can be.

    I corrected scene and Sunrise & Sunset VD so please download again and sorry for inconvenience. Thanks for helping clean some bugs. Still, it is better to first import "Sunrise & Sunset" VD so that global variables are properly set and formatted and then start the scene.

    Link to comment
    Share on other sites

    • 0

    Thank's! I still get the same error though, after installing the new Sunrise & Sunset. I removed the main scene before installing the new Sunrise & Sunset. I will check everything again.

     

    Cheers,

    Link to comment
    Share on other sites

    • 0

    Wow, looking good. this makes my system look like a child toy ;)

     

    I'm glued to the forum to see what else you are posting!!

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 16 minutes ago, robw said:

    Thank's! I still get the same error though, after installing the new Sunrise & Sunset. I removed the main scene before installing the new Sunrise & Sunset. I will check everything again.

     

    Cheers,

    When you change times on Sunrise & Sunset VD are times displayed correctly in format "00:00"? See posted picture above. This error is in function to calculate time difference and if value is not formatted correctly it will fail. Format must be with two digits for hours semicolon and two digits for minutes as "01:01".

     

    What I corrected in Sunrise & Sunset VD is only first initialization of global variables. When you add them in variable panel they get 0 as default value. When you first time press any of the buttons on VD to correct time this is checked and then formatted to string as "01:00" (before correction was to "00:00" but shortest time should be 1 hour). From there onward should be ok. If times are not shown as 0 or formatted time then you have to delete global variable and remake it (if you will loose some other tables if you save global variable panel) or just put 0 again and then use VD to format them to proper value.

    Link to comment
    Share on other sites

    • 0

    Ok, I will remove the global variables and test. I had made them beforehand, with value "00:00" (weeks ago).

    Link to comment
    Share on other sites

    • 0

    Ok, an update :) It must have been the Global Variables that had some issues. I removed and reinserted MarginDay, MarginNight, OpenBlindTime and MarginBlinds.

     

    Now the Main Scene works without errors! :)

     

    But, I guess there must be something weird going on, probably the Global Variables. If I make Changes in S&S, for instance I set sunrise or sunset a few minutes + or -, these changes is seen when I look in the variables section (and in the S&S ui). But if I change MarginDay, MarginNight, OpenBlindTime and MarginBlinds it only shows "00:00" in Variables (but in S&S ui and in the debug from Main Scene it shows the changes correctly).

     

    May I ask what is the correct way to add a Global Variable for these VD:s and Scenes?

    Shall I add for instance "MarginDay", remove the text "Value1" in the first field then "Value2" in the second field, then enter "00:00" in the first field and after that hit Save. After that is done, edit the Variable again, move "00:00" from the second field up to the first field, then delete the second field alltogether?

    Link to comment
    Share on other sites

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

    Ok, an update :) It must have been the Global Variables that had some issues. I removed and reinserted MarginDay, MarginNight, OpenBlindTime and MarginBlinds.

     

    Now the Main Scene works without errors! :)

     

    But, I guess there must be something weird going on, probably the Global Variables. If I make Changes in S&S, for instance I set sunrise or sunset a few minutes + or -, these changes is seen when I look in the variables section (and in the S&S ui). But if I change MarginDay, MarginNight, OpenBlindTime and MarginBlinds it only shows "00:00" in Variables (but in S&S ui and in the debug from Main Scene it shows the changes correctly).

     

    May I ask what is the correct way to add a Global Variable for these VD:s and Scenes?

    Shall I add for instance "MarginDay", remove the text "Value1" in the first field then "Value2" in the second field, then enter "00:00" in the first field and after that hit Save. After that is done, edit the Variable again, move "00:00" from the second field up to the first field, then delete the second field alltogether?

    Predefined global variables are variables where you have to give Value 1, Value 2 and so on and they are in lower section of the variable panel called "Predefined variables:". Global variables (without predefined) are numerical variables and when you make them by default they have value 0 and are in upper part of the variable panel just called "Variables".

     

    So, MarginDay, MarginNight, MarginBlinds, MarginSunrise, MarginSunset are to be made in "Variables:" upper part of the variable panel as numerical global variables.

     

    I also manage to replicate above error:

    Please login or register to see this code.

    and it is caused by missing local variable dayMargin. Since I tested scene before posting this was either deleted from code during copy/paste procedure or during setting up the scene by mistake. 

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 48 minutes ago, jompa68 said:

    @Sankotronic what part did i miss to setup if all my lights did turnOn at midnight? 

     

    Sorry @Sankotronic, was not your scene. I did play around with my ACWUT scene yesterday evening and it still was active...

    Hi @jompa68,

     

    You can't even imagine how many times I had similar situations, blinds opening at midnight, Angelina is wishing good night in the morning or not waking us up, etc. Of course cause of all this erratic events was ALWAYS me playing around with settings or changing code without proper testing afterwards. :-) 

     

    Once after testing some scenes I forget to turn off demo mode so of course again we stay in bed longer, lights didn't turn on. Angelina overslept and our kids where late for school. After that I learn our Angelina to warn me if I forget to put system in normal mode at least when we go to sleep.

     

    LEGEND

    Angelina = our HC2 :-P 

    Link to comment
    Share on other sites

    • 0
    8 hours ago, Sankotronic said:

    Predefined global variables are variables where you have to give Value 1, Value 2 and so on and they are in lower section of the variable panel called "Predefined variables:". Global variables (without predefined) are numerical variables and when you make them by default they have value 0 and are in upper part of the variable panel just called "Variables".

     

    So, MarginDay, MarginNight, MarginBlinds, MarginSunrise, MarginSunset are to be made in "Variables:" upper part of the variable panel as numerical global variables.

     

    I also manage to replicate above error:

    Please login or register to see this code.

    and it is caused by missing local variable dayMargin. Since I tested scene before posting this was either deleted from code during copy/paste procedure or during setting up the scene by mistake. 

     

    @Sankotronic Thank you for your quick replies with help! I feel utterly embarrassed... I had my Global Variables set in the lower part of the variables panel :oops: 

     

    Now I will shut up awhile and code and do right! :)

     

    Thank's again!

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 16 minutes ago, robw said:

     

    @Sankotronic Thank you for your quick replies with help! I feel utterly embarrassed... I had my Global Variables set in the lower part of the variables panel :oops: 

     

    Now I will shut up awhile and code and do right! :)

     

    Thank's again!

    Good morning @robw

     

    Please don't feel embarrassed. Believe me I went down this road of learning and had same problems, made same mistakes. Besides, global variable panel can be confusing because there is no any explanations what kind of global variable is for what and how to use them. Remember that there are no stupid questions, only stupid answers. That's why it is good that we have this forum to exchange knowledge and help each other!

     

    Link to comment
    Share on other sites

    • 0

    Thank you for your encouraging words, and all your help! I will try to learn coding these evenings, looking at your script, and migrate stuff to it. It will be nice to get rid of other timed events and let this beautiful script handle that :) Have a nice day!

    Link to comment
    Share on other sites

    • 0

    Hi Sankotronic,

     

    Quick question for you. Would it be possible to check in your code on github? It would make it easier to make sure one has the latest version and also to make suggestions with pull requests.

     

    Cheers,

    Tor Magnus

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 42 minutes ago, Tor Magnus said:

    Hi Sankotronic,

     

    Quick question for you. Would it be possible to check in your code on github? It would make it easier to make sure one has the latest version and also to make suggestions with pull requests.

     

    Cheers,

    Tor Magnus

    Hi @Tor Magnus,

     

    Thank yo for suggestion. I will definitely explore that possibility and will inform when is done.

    Link to comment
    Share on other sites

    • 0

    Can't wait to implement this when I get home. What do you use to determine if "Dad" is home or away?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 36 minutes ago, rasmusaabo said:

    Can't wait to implement this when I get home. What do you use to determine if "Dad" is home or away?

    In any of my scenes that are sending push, popup or e-mail notifications I use following simple solution:

     

    First under SETUP GLOBAL VARIABLES I add these two global variables:

    Please login or register to see this code.

    Then in function extraUserCodeFirst() I add this code:

    Please login or register to see this code.

    Of course you can use different name for DadAway and MomAway and change "Yes" and "No" to your language. Since userFlag is simple table variable, number in square brackets is determining position of flag to be changed. So in above example dad's userID is 200 and mom's ID is 240 in following setting:

    Please login or register to see this code.

     Of course, DadAway and MomAway can be set by some virtual device, or scene using GPS or any other way you find it most convenient for you. I just use VD so I can set them manually by pressing button.

     

    Link to comment
    Share on other sites

    • 0

    So in your setup you have to remember to push the away button when you leave your house to set global variable.

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