Ankündigung
Einklappen
Keine Ankündigung bisher.
- √ - Close all my shutters 15min before sunrise
Einklappen
X
-
I replace
byCode:sh.trigger('VoletOuverture',dt=trigg)
it worksCode:logic.trigger(dt=trigg)

Thanks a lot for your help
Einen Kommentar schreiben:
-
if you use logic.trigger() instead of sh.trigger() the logic name can be omitted
Einen Kommentar schreiben:
-
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:
-
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:
-
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:
-
I understand what you mean but i don't know how to re schedule the logic ?
Einen Kommentar schreiben:
-
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:
-
Great it works
i do this : logic.conf
volet_fermeture.py :Code:[VoletFermeture] filename = volet_fermeture.py crontab = sunset+15m [VoletOuverture] filename = volet_ouverture.py crontab = 30 7 * *
and volet_ouverture.py :Code:for item in sh.match_items('*.volet'): item('off')
Thanks a lotCode: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')
Einen Kommentar schreiben:
-
- √ - 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 ...Stichworte: -


Einen Kommentar schreiben: