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

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

    #2
    You can use crontab for logics as well
    Mit freundlichen Grüßen
    Niko Will

    Logiken und Schnittstelle zu anderen Systemen: smarthome.py - Visualisierung: smartVISU
    - Gira TS3 - iPhone & iPad - Mobotix T24 - ekey - Denon 2313 - Russound C5 (RIO over TCP Plugin) -

    Kommentar


      #3
      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

      Kommentar


        #4
        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.
        Mit freundlichen Grüßen
        Niko Will

        Logiken und Schnittstelle zu anderen Systemen: smarthome.py - Visualisierung: smartVISU
        - Gira TS3 - iPhone & iPad - Mobotix T24 - ekey - Denon 2313 - Russound C5 (RIO over TCP Plugin) -

        Kommentar


          #5
          I understand what you mean but i don't know how to re schedule the logic ?

          Kommentar


            #6
            Logics ? SmartHome.py 1.0 documentation
            Mit freundlichen Grüßen
            Niko Will

            Logiken und Schnittstelle zu anderen Systemen: smarthome.py - Visualisierung: smartVISU
            - Gira TS3 - iPhone & iPad - Mobotix T24 - ekey - Denon 2313 - Russound C5 (RIO over TCP Plugin) -

            Kommentar


              #7
              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 * *")

              Kommentar


                #8
                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.
                Mit freundlichen Grüßen
                Niko Will

                Logiken und Schnittstelle zu anderen Systemen: smarthome.py - Visualisierung: smartVISU
                - Gira TS3 - iPhone & iPad - Mobotix T24 - ekey - Denon 2313 - Russound C5 (RIO over TCP Plugin) -

                Kommentar


                  #9
                  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')

                  Kommentar


                    #10
                    if you use logic.trigger() instead of sh.trigger() the logic name can be omitted
                    Mit freundlichen Grüßen
                    Niko Will

                    Logiken und Schnittstelle zu anderen Systemen: smarthome.py - Visualisierung: smartVISU
                    - Gira TS3 - iPhone & iPad - Mobotix T24 - ekey - Denon 2313 - Russound C5 (RIO over TCP Plugin) -

                    Kommentar


                      #11
                      I replace

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

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

                      Thanks a lot for your help

                      Kommentar


                        #12
                        no worries
                        Mit freundlichen Grüßen
                        Niko Will

                        Logiken und Schnittstelle zu anderen Systemen: smarthome.py - Visualisierung: smartVISU
                        - Gira TS3 - iPhone & iPad - Mobotix T24 - ekey - Denon 2313 - Russound C5 (RIO over TCP Plugin) -

                        Kommentar

                        Lädt...
                        X