Ankündigung

Einklappen
Keine Ankündigung bisher.

- √ - Close all my shutters 15min before sunrise

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • 2ndsky
    antwortet
    no worries

    Einen Kommentar schreiben:


  • chrissou
    antwortet
    I replace

    Code:
    sh.trigger('VoletOuverture',dt=trigg)
    by

    Code:
    logic.trigger(dt=trigg)
    it works

    Thanks a lot for your help

    Einen Kommentar schreiben:


  • 2ndsky
    antwortet
    if you use logic.trigger() instead of sh.trigger() the logic name can be omitted

    Einen Kommentar schreiben:


  • chrissou
    antwortet
    Thanks for your advices

    My new code :

    Code:
    import random
    from datetime import timedelta
    
    exeption = sh.ical('https://www.google.com/calendar/ical/french__fr%40holiday.calendar.google.com/public/basic.ics')
    now = sh.now()
    
    if sh.system.absence.vacances() and now.hour == 7 and now.minute == 30:
            trigg = sh.now() + timedelta(minutes=random.randint(0, 180))
            sh.trigger('VoletOuverture',dt=trigg)
    elif (now.date() not in exeption and now.weekday() not in (5, 6)) or sh.system.absence.vacances():
            for item in sh.match_items('*.volet'):
                    item('on')

    Einen Kommentar schreiben:


  • 2ndsky
    antwortet
    With scheduler.change() you change the cron entry for this logic in my opinion. So your logic asking for hour == 7 and minute == 30 only works after restart

    Use sh.scheduler.trigger() instead to trigger the logic the second time each day. With this you do not change the cron entry itself.

    Einen Kommentar schreiben:


  • chrissou
    antwortet
    Alright

    i modify to reschedule and i include the public holiday with google calendar :

    Code:
    import random
    import time
    import datetime
    
    today = sh.now().date()
    exeption = sh.ical('https://www.google.com/calendar/ical/french__fr%40holiday.calendar.google.com/public/basic.ics')
    now = datetime.datetime.now()
    
    if sh.system.absence.vacances() and now.hour == 7 and now.minute == 30:
            hour = random.randint(8, 10)
            minute = random.randint(0, 30) if hour == 10 else random.randint(0, 59)
            sh.scheduler.change('VoletOuverture', cron="{} {} * *".format(minute,hour))
    elif (today not in exeption and now.weekday() not in (5, 6)) or sh.system.absence.vacances():
            for item in sh.match_items('*.volet'):
                    item('on')
                    sh.scheduler.change('VoletOuverture', cron="30 7 * *")

    Einen Kommentar schreiben:


  • 2ndsky
    antwortet
    Logics ? SmartHome.py 1.0 documentation

    Einen Kommentar schreiben:


  • chrissou
    antwortet
    I understand what you mean but i don't know how to re schedule the logic ?

    Einen Kommentar schreiben:


  • 2ndsky
    antwortet
    I'm not an expert for this, but the sleep will pause one thread just for waiting. It would be better to calculate a random datetime between 7:30 and 10:30 and add the logic again to the scheduler for this specific datetime. Then the scheduler can handle the thread resources.

    Einen Kommentar schreiben:


  • chrissou
    antwortet
    Great it works

    i do this : logic.conf

    Code:
    [VoletFermeture]
            filename = volet_fermeture.py
            crontab = sunset+15m
    
    [VoletOuverture]
            filename = volet_ouverture.py
            crontab = 30 7 * *
    volet_fermeture.py :

    Code:
    for item in sh.match_items('*.volet'):
            item('off')
    and volet_ouverture.py :
    Code:
    import random
    import time
    
    #if holidays open the shutter random between 7h30 and 10h30 
    if sh.system.absence.vacances:
            time.sleep(random.randint(0,180*60))
    
    for item in sh.match_items('*.volet'):
            item('on')
    Thanks a lot

    Einen Kommentar schreiben:


  • 2ndsky
    antwortet
    You can use crontab for logics as well

    Einen Kommentar schreiben:


  • chrissou
    hat ein Thema erstellt - √ - Close all my shutters 15min before sunrise.

    - √ - Close all my shutters 15min before sunrise

    Hello, i’m a noob in smarthome and i would like to use logical but i don’t know how.

    I would like to close all my shutters all days 15min before sunrise. I know i can use crontab on each item but i think i can do better with logical and something like sh.*.shutter maybe ? Is it possible how ?

    Thanks a lot

    PS : sorry for english but i didn't speak a word of german ...
Lädt...
X