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

calander events


Question

Posted

Hi

 

I have events like bank holidays or other holidays scattered throuout the year, I want to get date of the coming sunday unless a holiday is in between which in that case i want to get the date of the holiday.

 

How would you suggest is the best way of doing this?

7 answers to this question

Recommended Posts

  • 0
Posted

Maybe put the Sunday dates also in the list of holidays and get the first new date and show if it is a holiday or Sunday ?

  • 0
Posted (edited)

Here in Germany, I use 

Please login or register to see this link.

 and compare that against the date in

Please login or register to see this link.

.

 

I'm sure there are similar services in the UK.

Edited by jayrock
  • 0
  • Inquirer
  • Posted (edited)

        local currentDate = os.date("*t")

        local currentTimeSec = os.time(currentDate)
        local dayOfWeek = tonumber(os.date("%w"))
        dayOfWeek = 0
        while dayOfWeek < 6 do
            print(dayOfWeek,os.date("%d/%m/%Y",currentTimeSec))
            currentTimeSec = os.time(currentTimeSec) + 1 * 60*60*24
            dayOfWeek = tonumber(os.date("%w",currentTimeSec))
        end

    this does not work but not sure where i am going wrong, i am getting todays day of week and then i want add the rest of the of week, at the moment i am working to saturday which day 6, i have set day of week to sunday for testing.

    what i was thinking was to make a table and then insert the date of the week which i will then go and check for holidays, which i am already doing elswhere, so thinking i can use the same logic.

    Edited by Jay Ess
    • 0
    Posted (edited)

    What exactly do you want to achieve? Your code sets day of week to 0 regardless of the actual day.

    FWIW here is my scene, run each day at 0:01 hrs. It sets a global variable to true if there is public holiday (="Feiertag")

     

    Please login or register to see this code.

     

    Edited by jayrock
    • 0
  • Inquirer
  • Posted (edited)

    sorted sort of and just need to work out how to store the data

     

    Edited by Jay Ess
    • 0
  • Inquirer
  • Posted

    @jayrockthank you but i am trying to work out if there is a holiday in the coming week. for to work out if there today is public holiday, i download on the 1 jan at mdnight i list of public holidays which i store in a variable as a json encoded table and then daily at midnight i cycle through the days to get if today is a public holiday. the reason i am doing like that is because i am trying to minimise my system relying on the internet as would like to devleop a fully independent system which will work even without internet connection.

     

    for test purposes i set the day to 0 as i was working on this over the weekend and wanted to ensure that it would bring me the correct data.

     

    thank you for your help.

    • 0
    Posted
    22 hours ago, Jay Ess said:

    @jayrockthank you but i am trying to work out if there is a holiday in the coming week. for to work out if there today is public holiday, i download on the 1 jan at mdnight i list of public holidays which i store in a variable as a json encoded table and then daily at midnight i cycle through the days to get if today is a public holiday. the reason i am doing like that is because i am trying to minimise my system relying on the internet as would like to devleop a fully independent system which will work even without internet connection.

     

    for test purposes i set the day to 0 as i was working on this over the weekend and wanted to ensure that it would bring me the correct data.

     

    thank you for your help.

     

    You could store the results of the API call in another global variable so that you have it at hand even if there is no internet connection.

     

    There was another great article on how to use Properties-userDescription of the HC itself, I guess that would also work. Just push you json there. I'm using the code below in another scene (almost certain that I stole it somewhere)

     

    Please login or register to see this code.

     

    ({min = 0 , max =1 }is like a default value)

     

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