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
4 hours ago, Sankotronic said:

 

Hi @AutoFrank,

 

First you need to declare local variable under section -- LOCAL VARIABLES DEFINITIONS ---- like this:

Please login or register to see this code.

Then you need to add this line to function extraUserCodeFirst():

Please login or register to see this code.

Now you can use this variable to run scheduled action. In your case you can define like this:

Please login or register to see this code.

Of course wakeup_time must be formatted as "00:00".

 

 

Hi @Sankotronic

 

Quick syntax check with you

 

I am looking to run a scene at time.

 

If I put a time into line 282 (as below) it all works fine

local runSceneSchedHour        = {{"06:30"},{"07:55"}};

 

executing the following

local runSceneSchedName        = {"good morning sequence","Sunrise Light"}; -- line 263

local runSceneSchedID          = {jT.scene.goodMorning,jT.scene.SunriseLight}; -- line 265

 

I want to pull it from a global variable so I added in the "own code" section (after line 416) I added

local wakeup_time = tonumber(fibaro:getGlobalValue("WakeUp_time"))

 

and then adjust the schedule hour (line 282)

local runSceneSchedHour        = {{"wakeup_time"},{"07:55"}};

 

.. but it doesn't execute 

I thought the syntax around wakeup_time should have been

local runSceneSchedHour        = {{wakeup_time},{"07:55"}}; or

local runSceneSchedHour        = {wakeup_time,{"07:55"}}; 

 

but the scene won't save error free

 

any idea ?

 

1 hour ago, AutoFrank said:

 

Hi @Sankotronic

 

Quick syntax check with you

 

I am looking to run a scene at time.

 

If I put a time into line 282 (as below) it all works fine

local runSceneSchedHour        = {{"06:30"},{"07:55"}};

 

executing the following

local runSceneSchedName        = {"good morning sequence","Sunrise Light"}; -- line 263

local runSceneSchedID          = {jT.scene.goodMorning,jT.scene.SunriseLight}; -- line 265

 

I want to pull it from a global variable so I added in the "own code" section (after line 416) I added

local wakeup_time = tonumber(fibaro:getGlobalValue("WakeUp_time"))

 

and then adjust the schedule hour (line 282)

local runSceneSchedHour        = {{"wakeup_time"},{"07:55"}};

 

.. but it doesn't execute 

I thought the syntax around wakeup_time should have been

local runSceneSchedHour        = {{wakeup_time},{"07:55"}}; or

local runSceneSchedHour        = {wakeup_time,{"07:55"}}; 

 

but the scene won't save error free

 

any idea ?

 

=============================================================

 

Hi @Sankotronic

I defined the variable and spent the last hour trying to debug but I cant seem to get it working 

Would you mind giving it the once over (sorry, it's prob some thing stupid :-( but I cant seem to see it.)

 

If I replace the second wakeup_time on line284 with an actual time it works

the global variable is in the format 00:00 and can be read back okay

Do I need to declare the format some where

I added 419 as extra code to get the global variable value

 

thanks

-f

 

my code is below.. 

 

Please login or register to see this code.

 

 

Hi @Sankotronic

 

I fixed the declaration (no longer a table and never meant to be :-( )

 

still not working through

Please login or register to see this code.

and the extra code

 

Please login or register to see this code.

I switched on the debugging in your script and it looks like its not getting the time

 

 

 

Am I missing some square brackets or something else ? 

Thanks for helping

-f

Please login or register to see this attachment.

 

EDIT

I got it working by calling the global variable directly

local runSceneSchedHour        = {{fibaro:getGlobalValue("WakeUp_time")}};        

It looks like something between the declaration and the extra code isn't working

i can work it this way so all good

 

Still not working but I have a lead :-) leave it with me

 

Thanks again

 

 

 

Edited by AutoFrank
Link to comment
Share on other sites

  • 0
6 hours ago, Sankotronic said:

 

Hi @AutoFrank,

 

First you need to declare local variable under section -- LOCAL VARIABLES DEFINITIONS ---- like this:

Please login or register to see this code.

Then you need to add this line to function extraUserCodeFirst():

Please login or register to see this code.

Now you can use this variable to run scheduled action. In your case you can define like this:

Please login or register to see this code.

Of course wakeup_time must be formatted as "00:00".

 

 

Hi @Sankotronic

 

Quick syntax check with you

 

I am looking to run a scene at time.

 

If I put a time into line 282 (as below) it all works fine

local runSceneSchedHour        = {{"06:30"},{"07:55"}};

 

executing the following

local runSceneSchedName        = {"good morning sequence","Sunrise Light"}; -- line 263

local runSceneSchedID          = {jT.scene.goodMorning,jT.scene.SunriseLight}; -- line 265

 

I want to pull it from a global variable so I added in the "own code" section (after line 416) I added

local wakeup_time = tonumber(fibaro:getGlobalValue("WakeUp_time"))

 

and then adjust the schedule hour (line 282)

local runSceneSchedHour        = {{"wakeup_time"},{"07:55"}};

 

.. but it doesn't execute 

I thought the syntax around wakeup_time should have been

local runSceneSchedHour        = {{wakeup_time},{"07:55"}}; or

local runSceneSchedHour        = {wakeup_time,{"07:55"}}; 

 

but the scene won't save error free

 

any idea ?

 

 

==================================

Hi @Sankotronic

 

Still not working but I have narrowed down and think it might have something to do with the format of the global variable

 

I added some extra debug and confirmed that the extra code is being executed

the time to execute the scene variable that I called wut is making it to the function doSceneSched()  intact

but it doesn't appear to be stored correctly in the table #runSceneSchedHour

and the #runSceneSchedHour[1][1] is blank and the comparison to current time is never true

(see second last debug line in screen shot below)

 

I couldn't see where you turn the variable read into local runSceneSchedHour        = {{wut}};                                 

in to the table #runSceneSchedHour

 

Do I have the correct format with local runSceneSchedHour        = {{wut}};

 

or is there another issue here you can see

 

Please login or register to see this attachment.

Edited by AutoFrank
Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi @AutoFrank,

     

    I tested my self and then realized that I was giving you wrong information. I apologize for that! :oops: Here is how it can be done the easiest way. You don't need any local variables declaration so you can delete wakeup_time from local variables declaration.

    First you need to setup runSceneSchedHour and lets say that your setup looks like this:

    Please login or register to see this code.

    This "wakeup_time" can be any string value, can be "time", or "what" it really doesn't matter as long as it is some string with quotes!. After that you can see that position of this string is 1st table and also 1st in subtable, so you need to add following line to function extraUserCodeFirst()

    Please login or register to see this code.

    And that should work!

     

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Dear users of Main scene for time based events control!

     

    I just updated Sunrise & Sunset VD to version 1.3

     

    Please check my first post for details and download!

     

    Thank you and happy coding! :) 

    Link to comment
    Share on other sites

    • 0
    Just now, Sankotronic said:

    Dear users of Main scene for time based events control!

     

    I just updated Sunrise & Sunset VD to version 1.3

     

    Please check my first post for details and download!

     

    Thank you and happy coding! :) 

    thanks @Sankotronic  I am still at 1.2.2, does 1.2.4 cater for the incorrect debug for VD's? for example, my VD button press goes every 2 mins, and the button is 7.. it debug writes 7mins but actually performs as it should.. (hope that makes sense) its just the log that's incorrect...

    Link to comment
    Share on other sites

    • 0

    Hi @Sankotronic

     

    Just noticed that Sunrise & Sunset VD is still using "old-style" time calculation, might be a good idea to swap these out for the same one that is in the Main Scene so that they're all the same. From a cursory look they should all produce the same result.

     

    I might go through the VD this evening to do an update of the functions, I can send you the update in PM if it's possible. :)

     

    Cheers,

    Tor Magnus

    Edited by Tor Magnus
    Link to comment
    Share on other sites

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

    Hi @Sankotronic

     

    Just noticed that Sunrise & Sunset VD is still using "old-style" time calculation, might be a good idea to swap these out for the same one that is in the Main Scene so that they're all the same. From a cursory look they should all produce the same result.

     

    I might go through the VD this evening to do an update of the functions, I can send you the update in PM if it's possible. :)

     

    Cheers,

    Tor Magnus

    Hi @Tor Magnus,

     

    You are right, I forgot to replace them. I will greatly appreciate if you do that and send me update in PM!

     

    Thank you very much!

    Cheers!

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 33 minutes ago, shaunfrost said:

    thanks @Sankotronic  I am still at 1.2.2, does 1.2.4 cater for the incorrect debug for VD's? for example, my VD button press goes every 2 mins, and the button is 7.. it debug writes 7mins but actually performs as it should.. (hope that makes sense) its just the log that's incorrect...

     

    @shaunfrost,

     

    Thank you for pointing that. I just checked and it is again copy & paste mistake. :oops: I will correct code and then post new version together with Sunrise & Sunset VD when @Tor Magnus send it to me with cleaned code!

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Just now, Tor Magnus said:

    The pressure is clearly on me then. :shock: Good thing the wife is out of town and I can nerd as much as I want this evening. :mrgreen:

     

    Lucky you! We are all at home because we have blizzard outside. It started yesterday and it is still snowing with strong winds. I was busy adapting code so that blinds don't open, especially those looking at the North. Netatmo weather station is constantly sending warnings for strong winds! The good thing is that now at least I know is working properly! :P 

     

    3 minutes ago, Tor Magnus said:

    @Sankotronic,

    Also, I was wondering why f.ex. margDay is minimum 1 hour?

     

    Cheers,

    Tor Magnus

     

    Well, now that you will play with VD you can change that too! It is ok with me! :) 

    Link to comment
    Share on other sites

    • 0

    Please login or register to see this code.

    @Sankotronic i got a question for you :-D 

    Your example, will this mean that holyTimeOn will be 5min before "06:00" ?

    So will this work then, and time to when GlobalVariable changes will be 05:55?

    Please login or register to see this code.

     

    Please login or register to see this code.


     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hi @jompa68,

     

    It will work but you have few things to do. This time subtraction will give you result "05:55" and value in table on that position will be replaced with it:

    Please login or register to see this code.

    Since you are setting value of second subtable [2] first value [1] then chgGlobalHour looks like this:

    Please login or register to see this code.

    So "holyTime" string is replaced with "05:55" in second subtable first position! Instead of "holyTime" you can use any string value eg. for all you can use same string like "time" and then change value to desired time string:

    Please login or register to see this code.

    Just be careful with value position in the table! Also you don't need to declare any other local variable to do it. 

     

     

    Link to comment
    Share on other sites

    • 0
    16 minutes ago, Sankotronic said:

    Just be careful with value position in the table! Also you don't need to declare any other local variable to do it. 

    Thanks @Sankotronic will match perfect into my scene :mrgreen:

    Link to comment
    Share on other sites

    • 0

    Hi @Sankotronic

     

    Maybe a stupid question but will this scene automatically set the variables: morning, day, night and evening based on the VD Sunrise_&_Sunset_v1.2.vfib  or do I need to create a scene to to do this?

     

    cheers,

     

    Landshark

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Sunrise & Sunset VD and Main scene are working together. VD adjusts times and Main scene is changing time of day and darkness according to that settings.

     

    Short answer: Yes! :) 

    Link to comment
    Share on other sites

    • 0
    18 hours ago, Sankotronic said:

    local chgGlobalHour = {{"time"}, {"time", "time"}}; chgGlobalHour[1][1] = calculateTimeString(sunrise, "00:15", "add") chgGlobalHour[2][1] = calculateTimeString(sunset, "00:15", "substract") chgGlobalHour[2][2] = calculateTimeString(nightTime, "01:00", "add")

    Can confirm this work flawless @Sankotronic but i did not doubt it :-D

    Link to comment
    Share on other sites

    • 0

    Hi 

    Have created and saved HomeTable, Have created variable "Darkness". Have created Predefined variables "DemoMode","HomeTable","Month","SleepState",'TimeOfDay" and "WeekDay". without pressing save button

    Downloaded VD "sunrise and sunset" and copy and pasted "Main scene".

    Why when run would I get

    Please login or register to see this attachment.

    when scene is run ?

    Thankyou Jamie

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 3 hours ago, Jamie mccrostie said:

    Hi 

    Have created and saved HomeTable, Have created variable "Darkness". Have created Predefined variables "DemoMode","HomeTable","Month","SleepState",'TimeOfDay" and "WeekDay". without pressing save button

    Downloaded VD "sunrise and sunset" and copy and pasted "Main scene".

    Why when run would I get

    Please login or register to see this attachment.

    when scene is run ?

    Thankyou Jamie

     

    Hi @Jamie mccrostie,

     

    can you please check Sunrise & Sunset VD that all times are in format "00:00"? His seems like corrupted global variables after pressing SAVE in variables panel.

     

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