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


  • 0

Time Of Day use sunset offset


Question

Posted

Hello,

 

I have a script, found here, to set the time of day. This works fine, except that for the evening, in want to use 15 minutes before the sunset. I did try with blocks to take a look, and then convert to LUA, but i am not sure what to change.

 

Anyone who can help?

 

I have:

 

Please login or register to see this code.

And i found from converting a block to LUA:

Please login or register to see this code.

How can i use the 15 minutes offset, so that TimeOfDay is set to Evening, 15 minutes before sunset?

 

Can i use something like this:

 

Please login or register to see this code.

Any help is appreciated.

 

Thanks!

 

Regards,

Roland

 

 

Recommended Posts

  • 0
Posted

Hi, I have been trying to rewrite the timeofday script so that there's a difference between weekdays and weekends when 'night' is activated. Could one of you maybe point me in the right direction. The thing is that I need the night mode to be activated say 24:00 on weekdays and 01:30 on weekends.  

 

One possible approach is to have another script and global variable 'DayofWeek' which determines weekday or weekend, then modify this 'TimeofDay' script to incorporate the difference between weekday and weekend for night's timing. This approach allows other scenes that has similar needs to reuse the 'DayofWeek' global variable.

  • 0
Posted

I'd like to use a lux-meter reading from a Fibaro eye or similar to report the amount of daylight rather than sunrise-sunset, since sunny days or overcast are a huge difference. 

They ain't very weatherproof tough. Maybe it can look trough a window?

Or maybe a normal photoelectrical switch and an universal-sensor.

It need to update the homecenter quite often though.

It's a big difference in daylight winter vs summer at my place.

  • 0
Posted

Does this script run always ??? for you guys ????

 

i have found that it runs ok for one day then it gets stuck .... so either i have the variable stuck at evening or morning.....

 

in log i see no errors.... so what might hand this scene?????

 

 

cheers

 

 

Christos

  • 0
Posted

Not sure which script you are referring to. I have been using the one I shared (with some minor bugfix on typo) for weeks or months now and been working fine. One thing to note: This kind of scene needs to have the option "Do not allow alarm to stop scene..." option enabled. Not all scenes need to enable this option though. Only scenes like TimeOfDay, DayOfWeek.

  • 0
Posted

I'm using the post from Boerrmk in post #11
 
I still get the error:
 
[DEBUG] 23:48:17: morning: 06:30
[DEBUG] 23:48:17: evening: 18:42
DEBUG] 23:49:17: morning: 06:30
DEBUG] 23:49:17: evening: 18:42

Ect, Ect

  • 0
Posted

I'm using the post from Boerrmk in post #11

 

I still get the error:

 

[DEBUG] 23:48:17: morning: 06:30

[DEBUG] 23:48:17: evening: 18:42

DEBUG] 23:49:17: morning: 06:30

DEBUG] 23:49:17: evening: 18:42

Ect, Ect

 

Hi Jaapdeknaap,

 

It is debug info, no error. If you set debug to false or remove line 39 and 40 it will be gone.

  • 0
Posted

Hi, have set the stage for the shift variable, but variable does not change. Always gives an error:

[DEBUG] 22:37:58: Script started because of: autostart
[DEBUG] 22:37:58: Current Time: 22:37
[DEBUG] 22:37:58: Current time does not match any scenario.
[DEBUG] 22:38:53: Current Time: 22:38
[DEBUG] 22:38:53: Current time does not match any scenario.
[DEBUG] 22:39:48: Current Time: 22:39
[DEBUG] 22:39:48: Current time does not match any scenario.
Tell me what I do wrong?

  • 0
Posted

The scene does not switch the value of the variable what could be wrong? Firmware 4090.

  • 0
Posted (edited)

Hello, I am trying to use the script from borremk @ in this tread which includes:

...

local function toTimestamp(time, offset)
    currentDate = os.date("*t");
    hours, minutes = time:match("⌃(%d+)%d+)")
    return os.date("%H:%M", os.time({ year=currentDate.year, month=currentDate.month, day=currentDate.day, hour=hours, min=minutes, sec=seconds }) + (offset*60))
  end
 
  while true do
    local offsetSunrise = 0;
    local offsetSunset = -15;
    local night = "23:00";
    local day = "10:00";
    local sunrise = fibaro:getValue(1, "sunriseHour");
    local sunset = fibaro:getValue(1, "sunsetHour");
    local morning = toTimestamp(sunrise, offsetSunrise);
    local evening = toTimestamp(sunset, offsetSunset);
    local currentTime = os.date("%H:%M");
    local TimeOfDay = fibaro:getGlobal("TimeOfDay");
    
    log("morning: "..morning)
    log("evening: "..evening)

...

As I understand it, "morning" should return an offset time from sunrise, based on the value of "offsetSunrise". However, my logging of "morning" returns 12:00. If I alter the value for offsetSunrise to for example: 15, it returns 12:15.

I am thinking that the offset itself works, but I can not get it to offset from the current time of sunrise which is reported to be 07:53 in my area for today. Sunrise is reported correct if I log "sunrise"

 

 

[DEBUG] 20:02:22: HC2 start script at Mon Oct 29 20:02:22 2018
[DEBUG] 20:02:22: morning: 12:00
[DEBUG] 20:02:22: evening: 11:45
[DEBUG] 20:02:22: sunrise: 07:54
 

Can anyone, please assist on this?

 

 

 

 

 

Edited by japasu
  • 0
Posted

Can you change the line:

hours, minutes = time:match("^(%d+)%d+)")

in
hours, minutes = time:match("(%d+):(%d+)")

 

 

  • 0
Posted (edited)

Thank you, very much, for the rapid response tom my question.

I am sorry, but I actually use ("⌃%d+%d+") when the return is 12:00 if I change to ("^(%d+)%d+)") I get: 

[DEBUG] 21:46:54: [1;31m2018-10-29 21:46:54.582045 [ fatal] Unknown exception: /opt/fibaro/scenes/51.lua:25: invalid pattern capture

 

If I use ("^%d+%d+") I get 15:00 for lightson

The change for 12:00 and 15:00 is a different uparrow symbol

The brackets in you code gives me the invalid pattern capture mentioned above.

 

 

Update:

Thanks, again, I am really confused about this...

I think you helped my anyways:)

I tried: ("^(%d+):(%d+)") and it really seems to work now.

My original code did not include ":" in the match.

 

Thanks for you inputs that encouraged my to try more options.

Edited by japasu
  • 0
Posted

Good to hear that the new pattern is working for you.

  • Like 1

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