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

display sunset time


ErnstH

Question

Hi all,

I would like to display a debug message with the time of sunset + an x amount of minutes. So there needs to be a calculation.

I have a few scenes whose start is dependent of the month, turning lights on earlier or later.

My debug message should be something like "today lights will be on at 21:15". That 21:15 is the calculated time.

I have these declarations at the start of scenes:

local sunsettime    = fibaro:getGlobalValue("SunsetTime");
local sunsetHour   = fibaro:getValue(1,'sunsetHour')

But I can't figure out how to do this. Shouldn't be very complicated, but i'm not good in LUA programming with time.

Hope someone can help me out.

Link to comment
Share on other sites

Recommended Posts

  • 1
  • Inquirer
  • 10 hours ago, 10der said:

    @ErnstH OK! Sir! trying to help you!

     

    Please login or register to see this code.

    Please login or register to see this link.

    is the what you asking?

     

     

    Hi 10der,

    Looks good though quite complicated. But I understand it.

    I pasted it into my script and it returns an error, that hmstr seems to be undefined yet:

    [DEBUG] 20:46:20: nil nil
    [DEBUG] 20:46:20: 2020-08-11 20:46:20.915000 [ fatal] Unknown exception: /opt/fibaro/scenes/5.lua:47: attempt to index local 'hmstr' (a nil value). Shouldn't that as well as margin be defined before the function?

    Nearly there I guess...

    Link to comment
    Share on other sites

    • 0

    Have you tried creating a block scene that activates say 10 mins after sunset (there is a standard block for this), and then converting that scene to LUA?

    Link to comment
    Share on other sites

    • 0

    Hope this VD can help you better understand the LUA code for what you want. 

     

    I've found this VD a while ago but I don't know the creator, all the credits are for him or her ?

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    Please login or register to see this image.

    /monthly_2020_08/image.png.bf073027e3365b33286198a3fb4d6219.png" />image.png.1903cbe4edeee44b796552de091b3d6e.png

     

    Please login or register to see this attachment.

     

     

    • Thanks 1
    Link to comment
    Share on other sites

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

    creating a block scene

    That is not the problem.

    I do have such a code: if os.date("%H:%M", os.time()+tonumber(BeforeSunset)*60) == sunsetHour   This works fine.

    But I want it the other way around: with a print of debug command I want to display the time lamps go on today.

    Thanks for trying to help.

    Link to comment
    Share on other sites

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

    Hope this VD can help you better understand the LUA code for what you want. 

     

    I've found this VD a while ago but I don't know the creator, all the credits are for him or her ?

    Please login or register to see this attachment.

    Thanks for the suggestion. I looked into that. Not just what I'm looking for, it is code I already have. Just displaying sunset time.

    Not with a calculation.

    I think I need something like os.date("%H:%M", os.time() = sunsetHour - tonumber(BeforeSunset)*60). But I need a better syntax.

    5 hours ago, 10der said:

    Please login or register to see this link.

    Please login or register to see this link.

     

    Please login or register to see this attachment.

     

     

    maybe, but how do I open or import this type of file?

    Link to comment
    Share on other sites

    • 0

    @10der - that looks good, i could benefit from something like that

    Quote
    17 hours ago, 10der said:

    Sun_calc.fqa 12.11 kB · 8 downloads

     

     

    Does it work on HC3, is this a QuickApp?

     

    I tried adding the file but it just adds as a generic device with no code by the looks of it (com.fibaro.genericDevice)

    Link to comment
    Share on other sites

    • 0
    4 minutes ago, theuksbest said:

    @10der - that looks good, i could benefit from something like that

     

    Does it work on HC3, is this a QuickApp?

     

    I tried adding the file but it just adds as a generic device with no code by the looks of it (com.fibaro.genericDevice)

    maybe cuz you have old HC3 fw?

    @theuksbest

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    @10der 

    12 minutes ago, 10der said:

    maybe cuz you have old HC3 fw?

     

    Correct! :) Thank you!

     

    Looks like it's working now, but..

    819552681_Screenshot2020-08-10at08_53_14.png.6b8d896d03d688d77ff57a2c058ab4b6.png

     

    it doesn't seem to load an icon. Did i do something wrong?

    Please login or register to see this attachment.

     

    Link to comment
    Share on other sites

    • 0

    @theuksbest sorry. you can't.

    setting icons for generoic deivce is tricky.

     

    btw, check global params for a new global param value.

    thanks

    Link to comment
    Share on other sites

    • 0

    @10der 

    Please login or register to see this image.

    /monthly_2020_08/1828987670_Screenshot2020-08-10at09_19_55.png.87e53005203331668e048df95f9db3d2.png" />

     

    still learning here: i don't see any new ones added, should i add something here?

     

    I have my Day/Night ones which i use in my scenes currently:

    Please login or register to see this attachment.

     

     

    @ErnstH - sorry and thank for letting me hijack your thread for a bit! :)

    Link to comment
    Share on other sites

    • 0

    @theuksbest hust create 

    DayPart

    like

    Please login or register to see this image.

    /monthly_2020_08/image.png.e85c035e0973782cac53c786b4b87091.png" />

     

    after 1 min variable should re-filled

    than you can use this var with more details sun events

     

        "nauticalDawn"-- 1
        "blueHourDawn"-- 2
        "dawn"-- 3
        "blueHourDawnEnd"-- 4
        "sunrise"-- 5
        "sunriseEnd"-- 6
        "goldenHourEnd"-- 7
        "solarNoon"-- 8
        "goldenHour"-- 9
        "sunsetStart"-- 10
        "sunset"-- 11
        "blueHourDusk"-- 12
        "dusk"-- 13
        "blueHourDuskEnd"-- 14
        "nauticalDusk"-- 15
        "night"-- 16
        "nadir"-- 17
        "nightEnd" -- 18
     
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 11 hours ago, theuksbest said:

    for letting me hijack your thread

    That's okay, that's what forums should do sometimes. ?

    Meanwhile, my question remains unresolved.

    Link to comment
    Share on other sites

    • 0

    @ErnstH OK! Sir! trying to help you!

     

    Please login or register to see this code.

    Please login or register to see this image.

    /monthly_2020_08/image.png.5b628d0fb9fbb7e8831e937a243b13f9.png" />

    is the what you asking?

     

     

    Edited by 10der
    Link to comment
    Share on other sites

    • 0

    @theuksbest now some magic.

    find in your HC3 device with Humidity (for example)

    ok found!

    change a new icon

    uploading nice icon for sunset

    done.

    do not change device.

    just check what a new icon uploaded.

    the next step - find icon id

    Please login or register to see this attachment.

     

    [M[ - 1040

     

    open your QA.

    find self:updateProperty("deviceIcon",  and finallu change to 1040

     

    self:updateProperty("deviceIcon", 1040)

     

     

    • Like 2
    Link to comment
    Share on other sites

    • 0

    10der is king :)
    If the HC3 was the old fw (5.031), I couldn't change the icon for the "com.fibaro.deviceController" device (QA).
    After upgrading to fw 5.040, this tweak can be used.
    Thanks.

    • Thanks 1
    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...