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


Question

Posted (edited)

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 16
  • Thanks 6

Recommended Posts

  • 0
Guest ErnstH
Posted

This works. However, the slider seems to have a value, which is indicated by the number to the right of it, but it also has a slider position. After changing blinds position the value to the right changes to the proper value, but the slider doesn't move (see example). It seems to be something like: id, "setProperty", "ui.slider1.handle.position"... however, that piece of code doesn't do it.

On 10-5-2017 at 11:21 PM, Sankotronic said:

-- updates slider position and runs code for slider fibaro:call(id, "setSlider", "2", "0");

What do you mean with "executing code for the slider "?

I don't understand this piece of code.

  • 0
  • Inquirer
  • Posted

    if you use function setSlider then it will also execute code that is in code window for that slider, same as if you adjust slider with your finger. The other one ui.Slider1.value is only setting slider position without running code for that slider. I'm sorry if you don't get it, my English is not so good and I can't explain it better.

     

    I also mentioned that if you are checking slider on web GUI interface or in internet browser connected to HC then slider will not move as expected but only number will show new position. You need to check it in mobile application, there it works or refresh page in browser.

    • 0
    Guest ErnstH
    Posted

    Your English is very well, it's not about that. I didn't understand (id, "setslider", "2","0"). What do these 2 and 0 refer to?

    By the way, it is working!! I don't know why, for I didn't make any new changes. Thanks Sanko!

    • 0
  • Inquirer
  • Posted
    4 hours ago, ErnstH said:

    Your English is very well, it's not about that. I didn't understand (id, "setslider", "2","0"). What do these 2 and 0 refer to?

    By the way, it is working!! I don't know why, for I didn't make any new changes. Thanks Sanko!

     

    Hi @ErnstH,

     

    id is ID number of the VD on which is slider. "2" is position of the slider on the VD. How positions are counted you can see from this picture:

    Please login or register to see this attachment.

     

     "0" is the value to which you want to set slider and can be from 0 to 100. If you use this one then code for that slider will execute. So if you just want to update slider position without other action then you should use the other function:

    Please login or register to see this code.

    where id is ID number of the VD, Slider1 in "ui.Slider1.value" is ID of slider and you need to give ID of your slider and position is value from 0 to 100 to which you want to set slider to. I checked code that I provided in my post #361 above and I corrected it.

    • 0
    Posted

    Hello @Sankotronic,

     

    I just like to say a big thank you for all the information you have posted. It makes for very interesting reading!

     

    I'm having trouble with using your code. (it could very well be me as I have never used LUA code) 

    I believe i have filled in the necessary details within the code but i'm getting this message below.

     

    Please login or register to see this attachment.

     

    I have updated to the latest software version 4.122 Beta could it be that? I see that the version you have is 4.120 could this be my issue?

     

    Thank you 

    • 0
  • Inquirer
  • Posted

    Hi @Crofty, and welcome to the Fibaro forum!

     

    There is answer in this topic, but to make it short, you should not use SAVE button in variable panel until I release new version. Using SAVE button in variables panel corrupts some of the global variables used by this scene. To correct this error you need to open Sunrise & Sunset VD and press there SAVE button to rebuild variables. After that you will need to adjust times again.

     

    • 0
    Posted

    @Sankotronic, Thanks for quick reply.

     

    I will have another look through the post, and try and understand. Sorry Newbie to coding and Fiabro HC2.

     

    @Sankotronic

     

    I have found where I was going wrong! Had the sunset and sunrise VD in the wrong room! Sorry

    • 0
    Posted

    Hi @Sankotronic

     

    About SeasonState.

     

    Which monts are winter, Summer Autumn and spring in the main scene?

     

    We are in June, but Main scene still says spring.

     

    This is how we define the seasons in my area:

    • Spring - from March 1 to May 31;

    • Summer - from June 1 to August 31;

    • Fall (autumn) - from September 1 to November 30; and,

    • Winter - from December 1 to February 28 (February 29 in a 

      Please login or register to see this link.

      ).

       

      Did I do something wrong or is this a bug?

    • 0
  • Inquirer
  • Posted
    On 6/3/2017 at 0:38 PM, TurboWannaBe said:

    Hi @Sankotronic

     

    About SeasonState.

     

    Which monts are winter, Summer Autumn and spring in the main scene?

     

    We are in June, but Main scene still says spring.

     

    This is how we define the seasons in my area:

    • Spring - from March 1 to May 31;

    • Summer - from June 1 to August 31;

    • Fall (autumn) - from September 1 to November 30; and,

    • Winter - from December 1 to February 28 (February 29 in a 

      Please login or register to see this link.

      ).

       

      Did I do something wrong or is this a bug?

     

    Hi @TurboWannaBe,

     

    you have good point. I always thought that season can start only on astronomical days of solstice or equinox, but there is also meteorological days as you mentioned in your post. I will add possibility that users can select either Astronomical or meteorological seasons.

     

    So current version has only astronomical seasons and spring starts on 20 March (March Equinox), summer starts on 21 June (June Solstice), autumn starts on 22/23 September (September Equinox) and winter starts on 21 December (December Solstice).

     

    I will then add meteorological seasons so that spring start on 1 March, summer start on 1 June, autumn (fall) start on 1 September and winter start on 1 December. Is that good enough or you also want me to add manual dates when each season start?

     

    • 0
    Posted

    Hi @Sankotronic,

     

    it seems that it's becoming a complex matter, because to do it right for at least the implemented languages by Fibaro, There will be implementation needed of different language dependent

    Please login or register to see this link.

    , which will require a quite complex algorithm see Wikipedia.

    Also the season definitions can differ enormouslly for example the chineese spring starts with chinese new year etc.

    Seems to be "mission impossible"?!?

     

     

    • 0
  • Inquirer
  • Posted
    25 minutes ago, Bodyart said:

    Hi @Sankotronic,

     

    it seems that it's becoming a complex matter, because to do it right for at least the implemented languages by Fibaro, There will be implementation needed of different language dependent

    Please login or register to see this link.

    , which will require a quite complex algorithm see Wikipedia.

    Also the season definitions can differ enormouslly for example the chineese spring starts with chinese new year etc.

    Seems to be "mission impossible"?!?

     

     

     

    Hi @Bodyart,

     

    Well, You are only partly right, because if I add possibility to manually setup dates then it is covered for the biggest part of the world. Some countries have 6 seasons but In that case they will have to do it themselves or be happy with only four seasons. But looking at global warming and climate changes, in future we may have only one long hot summer season LOL!

    • 0
    Posted

    Agree @Sankotronic, but that implies, that some users will have to do manual setup each year :-D

     

    • 0
  • Inquirer
  • Posted
    1 minute ago, Bodyart said:

    Agree @Sankotronic, but that implies, that some users will have to do manual setup each year :-D

     

     

    Not really, since you use first day of the month to change season and not last. Meteorological spring season is starting on 1st March so I don't really need to check if February has 28 or 29 days. Also, for astronomical seasons, this can be difference of one day and what really means if Angelina starts summer day earlier or day later? I don't really think that accuracy in that matter  of +/- one day makes any difference, but maybe I'm wrong and I don't see something? Is there anything very important that is related to the seasons regarding our homes that needs seasons to change at exact date and hour?

     

     

    • 0
    Posted
    1 minute ago, Sankotronic said:

     

    Not really, since you use first day of the month to change season and not last. Meteorological spring season is starting on 1st March so I don't really need to check if February has 28 or 29 days. Also, for astronomical seasons, this can be difference of one day and what really means if Angelina starts summer day earlier or day later? I don't really think that accuracy in that matter  of +/- one day makes any difference, but maybe I'm wrong and I don't see something? Is there anything very important that is related to the seasons regarding our homes that needs seasons to change at exact date and hour?

     

     

    In some cultures/countries the seasons can shift from year to year. And ofcourse i agree, that there are no season critical events in HA.

     

    • 0
  • Inquirer
  • Posted
    2 minutes ago, Bodyart said:

    In some cultures/countries the seasons can shift from year to year. And ofcourse i agree, that there are no season critical events in HA.

     

     

    Well, that is true, if you look from culture side then there is really a big variety in number of seasons and their changes trough out the year. That will be really mission impossible to cover especially where seasons are defined ecologically and not based on calendar.

     

    Since there is still a lot of work for me to do, for now I will keep it simple and provide seasons change based on calendar only, astronomical, meteorological. I can always add more possibilities later but then I will need help with details :-) 

    • 0
    Posted

    hi @Sankotronic, this might be a stupid question ( like a lot of my questions :) ), the timings for night to morning  , afternoon to evening and evening to night.  As i understand it they are adjusted by the +/- time ont he vd from sunrise and sunset. Is there a way of making it more automated. my reason being as the days get longer the sun rises earlier and sets later and the opp in the winter. to save have to adjust the timings often can there be a ...in winter darkness comes before the evening starts and in the summer it can be light till 10 then evening and night get squeezed in pretty close. Or i guess the other option is to be able to say morning starts @ 8am, evening starts @ 6.30pm etc...

    or have you already considered this and you'll tell me...

    in this section of the code  you can change this button to take all that into account :D

    thanks

    ed

    • 0
  • Inquirer
  • Posted
    8 hours ago, Edb said:

     

    hi @Sankotronic, this might be a stupid question ( like a lot of my questions :) 

     

     

    Hi @Edb,

     

    first of all, there are no stupid questions, only stupid answers! :-) 

     

    8 hours ago, Edb said:

    the timings for night to morning  , afternoon to evening and evening to night.  As i understand it they are adjusted by the +/- time ont he vd from sunrise and sunset. Is there a way of making it more automated. my reason being as the days get longer the sun rises earlier and sets later and the opp in the winter. to save have to adjust the timings often can there be a ...in winter darkness comes before the evening starts and in the summer it can be light till 10 then evening and night get squeezed in pretty close. Or i guess the other option is to be able to say morning starts @ 8am, evening starts @ 6.30pm etc...

     

    I understand your problem because I asked that myself. In current version Darkness changes value to Light and morning starts on sunrise time or at defined margin time so it is changing as sunrise time changes. Since morning is shifting then also time when day starts shifts too. Same applies for Darkness changing value to Dark and evening and night time.

     

    In new version I just introduced fixed times for morning, day, evening and night times, but I have feeling that this will not be enough for some users because changing of Darkness is still happening when time of day changes to morning or evening time.

     

    It is of course clear that it will always became dark around sunset but it can be before real sunset time if home is on the East side of big mountain so sun actually set much before it is calculated for that region or sometimes even after sunset time because of nice weather and twilight can last longer.

     

    So, for now, I can just do that Darkness is always changed at sunrise and sunset margin times while times of day can be set to change at that same times or at fixed times. Would that be good enough for you?

     

     

     

    • 0
    Posted

    Hi @Sankotronic,

     

    There is an issue in calculations in doTimeOfDay(). I'm living in Norway and sunrise and sunset changes quite a lot between summer and winter. To avoid an early night in winter I have marginNight set to +3, however currently sunset is ~22:30, which means my nighttime is 01:30. From a lighting perspective this may not be much of an issue, however line 512 is " elseif ((TimeCurrent >= sunsettime) and (TimeCurrent < nighttime)) then" which does not work if nighttime crosses 24:00. At that point you will never have Evening.

     

    I've been contemplating how to deal with this and I don't have any easy answers. Currently I'm capping nighttime to 24:00, but I'm actually considering whether to just set the transitions between the phases of the day permanently.

     

    Cheers,

    Tor Magnus

    • 0
  • Inquirer
  • Posted (edited)

    Hi @Tor Magnus,

     

    It is true that function doTimeOfDay() does not work properly if sunset time is before midnight while nighttime is after midnight because then sunset time is greater than nighttime. Also if sunsettime is after midnight and therefore smaller than daytime. In new version I have rewritten this function to better handle this times when difference between day time and night time is greater as you move more to the Earth poles. Here is new function to replace the old one:

    Please login or register to see this code.

    You only need to copy above function over the old one and test it. New Sunrise & Sunset VD also gives more freedom with setting times of day than the old one. But I still need to do some more testing before I can post new version here. I tested this function extensively and it is now running on my HC, but if you can test it in real life too it will be even better. Please, let me know if this solves your problem. Thank you!

     

    Edited by Sankotronic
    • 0
    Posted

    That does indeed look like it will fix it, however the gT/bT variables don't exist in the old version. Replaced that line with the line from the old script. Looks like it's ok now.

     

    Cheers,

    Tor Magnus

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