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

Kalendarz dni wolnych


Question

Guest rafal_ll
Posted (edited)

 

W HC2 miałem scenę zmieniającą zmienną którą można wykorzystywać w scenach, autorem był  

Please login or register to see this link.

Please login or register to see this link.

.

Może macie już podobne rozwiązanie do HC3 ?

Edited by rafal_ll

11 answers to this question

Recommended Posts

  • 0
Guest Rafal_ll
  • Inquirer
  • Posted

    Szkoda że nikt nie korzysta z takiego rozwiązania

    • 0
    Posted (edited)
    W dniu 3.05.2020 o 18:38, jgab napisał:

    Ok, bad topic of the thread (not only for Sweden now) but here is a more international version using the 

    Please login or register to see this link.

    service that @Sjakie pointed at.

    Please login or register to see this attachment.

    You will manage the free tier as it calls the api once a day, ~30 times a month, and it's free for 1000/month.

     

    quickAppVariables:

    'api_key' - the api key you get when you register

    'country' - country code according to their api

    'language' - only if you pay you get the data in your language of choice - otherwise english

    'weekends' - if set to "no" will not consider weekends as work free days (default is yes)

     

    This behaves a bit different. The QA is of type binarySwitch and will be on when it's a holiday (or weekend) and off when not (when it's a work day)

    This way it's easy to test if the QA is on or off.

    It also supports turnOn and turnOff commands to override the automatic setting. If you wake up in the morning and decides it should be holiday anyway... :-) 

     

    Feel free to improve.

    Jak to nie?? @jgab zrobił takie QA, sam z niego korzystam

    Edited by michal85pl
    • 0
    Posted (edited)

    jesli potrzebujesz samych wakacji, a nie "wakacje kociego dnia": 

    Please login or register to see this attachment.

     

    Please login or register to see this attachment.

     

    Please login or register to see this image.

    /monthly_2021_01/image.png.c685650109c82453bd5f90fba4fe6cb6.png" />

     

    Please login or register to see this link.

     (MicroSoft) (FREE!)

    Edited by 10der
    • 0
    Posted

    Oleg "wakacje kociego dnia" - cat day holiday. :D

    • 0
    Posted (edited)
    1 hour ago, XTeK said:

    Oleg "wakacje kociego dnia" - cat day holiday. :D

    Yep ;) right 

    that was my basic idea ;) for exclude some holidays when you works and not rest ;) 

    so this QA can alert ONLY if working day is holiday and you can make additional automation based on it ;) 

    thanks dear!

    Edited by 10der
    • 0
    Guest Rafal_ll
  • Inquirer
  • Posted

    Dzięki wielkie

    Muszę przetestować wasze rozwiązania 

    Wszystkie te rozwiązania są fajne  opierają się o zewnętrzne źródła danych.

     

    Na HC2 miałem taką scenę bez pobierania danych

    Nie pamiętam kto był twórcą, ale działała świetnie.

     

     

     

     

    --[[ 
     %% autostart 
     %% properties 
     %% globals 
     --]] 

     local sourceTrigger = fibaro:getSourceTrigger(); 
     if (sourceTrigger["type"] == "autostart") then 
     while true do 

     local currentDate = os.date("*t"); 
     local startSource = fibaro:getSourceTrigger(); 
     if ( 
      ( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "00:01") ) 
     ) 
     then 
           wolny=0 
       rok=os.date("%Y") 
       zm = (rok % 19) + 1 
       c = math.floor(rok/400) + math.floor(8*(math.floor(rok/100)+11)/25) - math.floor(rok/100) 
       s = (11 * zm + c) % 30 
       if (s < 0) then 
         s = s + 30 
       end 
       pfm = os.time{year=rok, month=4, day=19} - s * 24 * 60 * 60 
       if (pfm == os.time{year=rok, month=4, day=19}) then 
         pfm = pfm - 24 * 60 * 60 
       elseif (pfm == os.time{year=rok, month=4, day=18} and zm > 11) then 
         pfm = pfm - 24 * 60 * 60 
       end 
       niedz = pfm + (7 - tonumber(os.date("%w", pfm))) * 24 * 60 * 60 
       poniedz = niedz + 1 * 24 * 60 * 60 
       bozec = niedz + 60 * 24 * 60 * 60 

       wielkanoc = os.date("%m", niedz)..os.date("%d", niedz)  
       lanyponiedz= os.date("%m", poniedz)..os.date("%d", poniedz) 
       bozecialo= os.date("%m", bozec)..os.date("%d", bozec) 
       
     t= {"0101","0106","0501","0503","0815","1101","1111","1225","1226"} 

     table.insert(t,lanyponiedz) 
     table.insert(t,bozecialo) 

     data= tostring(os.date("%m%d")) 
     fibaro:debug(data) 
     for a, b in pairs(t) do 
      if data==b then 
     wolny = 1 
       end 
     end 

     local dzis = os.date("*t"); 
     if  (dzis.wday == 1 or dzis.wday == 7) or wolny == 1 then 
     fibaro:debug("Dzień wolny : TAK") 
     fibaro:setGlobal("dzien_wolny",1) 
     else 
     fibaro:debug("Dzień wolny : NIE") 
     fibaro:setGlobal("dzien_wolny",0)  
     end 

     end 

     fibaro:sleep(60*1000); 
     end 
     else 

     local currentDate = os.date("*t"); 
     local startSource = fibaro:getSourceTrigger(); 
     if ( 
     startSource["type"] == "other" 
     ) 
     then 
       wolny=0 
       rok=os.date("%Y") 
       zm = (rok % 19) + 1 
       c = math.floor(rok/400) + math.floor(8*(math.floor(rok/100)+11)/25) - math.floor(rok/100) 
       s = (11 * zm + c) % 30 
       if (s < 0) then 
         s = s + 30 
       end 
       pfm = os.time{year=rok, month=4, day=19} - s * 24 * 60 * 60 
       if (pfm == os.time{year=rok, month=4, day=19}) then 
         pfm = pfm - 24 * 60 * 60 
       elseif (pfm == os.time{year=rok, month=4, day=18} and zm > 11) then 
         pfm = pfm - 24 * 60 * 60 
       end 
       niedz = pfm + (7 - tonumber(os.date("%w", pfm))) * 24 * 60 * 60 
       poniedz = niedz + 1 * 24 * 60 * 60 
       bozec = niedz + 60 * 24 * 60 * 60 

       wielkanoc = os.date("%m", niedz)..os.date("%d", niedz)  
       lanyponiedz= os.date("%m", poniedz)..os.date("%d", poniedz) 
       bozecialo= os.date("%m", bozec)..os.date("%d", bozec) 
       
     t= {"0101","0106","0501","0503","0815","1101","1111","1225","1226"} 

     table.insert(t,lanyponiedz) 
     table.insert(t,bozecialo) 

     data= tostring(os.date("%m%d")) 
     fibaro:debug(data) 
     for a, b in pairs(t) do 
      if data==b then 
     wolny = 1 
       end 
     end 

     local dzis = os.date("*t"); 
     if  (dzis.wday == 1 or dzis.wday == 7) or wolny == 1 then 
     fibaro:debug("Dzień wolny : TAK") 
     fibaro:setGlobal("dzien_wolny",1) 
     else 
     fibaro:debug("Dzień wolny : NIE") 
     fibaro:setGlobal("dzien_wolny",0)  
     end 

     end 

     end 

     

     

     

     

     

    • 0
    Posted
    1 hour ago, Rafal_ll said:

     t= {"0101","0106","0501","0503","0815","1101","1111","1225","1226"} 

    ?

    • 0
    Posted
    21 godzin temu, Rafal_ll napisał:

    Na HC2 miałem taką scenę bez pobierania danych

    Nie pamiętam kto był twórcą, ale działała świetnie.

    No niby tak, ale sztuka polega na tym właśnie, żeby dni wolne aktualizowały się same, bo wpisywanie ręczne to słaba opcja...

    • 0
    Guest Rafal_ll
  • Inquirer
  • Posted (edited)
    2 godziny temu, michal85pl napisał:

    No niby tak, ale sztuka polega na tym właśnie, żeby dni wolne aktualizowały się same, bo wpisywanie ręczne to słaba opcja...

    To było  zrobione na zasadzie wyliczenia, kalendarz się powtarza

    Please login or register to see this link.

    Edited by Rafal_ll
    • 0
    Guest Rafal_ll
  • Inquirer
  • Posted
    W dniu 12.01.2021 o 21:00, michal85pl napisał:

    Jak to nie?? @jgab zrobił takie QA, sam z niego korzystam

     Próbuję z niego korzystać bez większych sukcesów 

    Przejście w dzień wolny działa  , ale w drugą stronę niechętnie.

    O jakiej  godzinie  to się aktualizuje ?

    • 0
    Posted (edited)

    Cześć wszystkim! Odkopuję może trochę temat ale mam pytanie. Czy ktoś wie jak zmienić poniższą scenę tak, aby do dni pracujących dodać także soboty? Chce aby dniami wolnymi były tylko niedziele oraz dni ustawowo wolne (także święta ruchome) oraz niedziele. Z góry dziękuję za pomoc! 

     

     

    Deklaracje:

     

    {
      conditions = { {
          isTrigger = true,
          operator = "match",
          property = "cron",
          type = "date",
          value = { "01", "00", "*", "*", "*", "*" }
        } },
      operator = "all"
    }

     


    Akcja:

     

    wolny=0
    rok=os.date("%Y")
    zm = (rok % 19) + 1
    c = math.floor(rok/400) + math.floor(8*(math.floor(rok/100)+11)/25) - math.floor(rok/100)
    s = (11 * zm + c) % 30

    if (s < 0) then
        s = s + 30
    end

    pfm = os.time{year=rok, month=4, day=19} - s * 24 * 60 * 60

    if (pfm == os.time{year=rok, month=4, day=19}) then
        pfm = pfm - 24 * 60 * 60
    elseif (pfm == os.time{year=rok, month=4, day=18} and zm > 11) then
        pfm = pfm - 24 * 60 * 60
    end

    niedz = pfm + (7 - tonumber(os.date("%w", pfm))) * 24 * 60 * 60
    poniedz = niedz + 1 * 24 * 60 * 60
    bozec = niedz + 60 * 24 * 60 * 60
    wielkanoc = os.date("%m", niedz)..os.date("%d", niedz)
    lanyponiedz= os.date("%m", poniedz)..os.date("%d", poniedz)
    bozecialo= os.date("%m", bozec)..os.date("%d", bozec)
    t= {"0101","0106","0501","0503","0815","1101","1111","1225","1226"}
    table.insert(t,lanyponiedz)
    table.insert(t,bozecialo)
    data= tostring(os.date("%m%d"))


        for a, b in pairs(t) do
            if data==b then
                wolny = 1
            end
        end


        local dzis = os.date("*t");
        if (dzis.wday == 1 or dzis.wday == 7) or wolny == 1 then
            fibaro.debug("dzienWolny", "Dzien wolny : TAK")
            fibaro.setGlobalVariable("dzienWolny", '1')
        else
            fibaro.debug("{dzienWolny}", "Dzien wolny : NIE")
            fibaro.setGlobalVariable("dzienWolny", '0')
        end

    Edited by pavloosz

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