Example #1
0
 def read_config(self):
     """lit le fichier de configuration"""
     cfg = read_conf(self.CONF_FILE)
     self.channel = cfg['channel']
     self.seuil_min = cfg['seuil_min']
     self.last_level = cfg['last_level']
     self.last_level_date = cfg['last_level_date']
Example #2
0
 def read_config(self):
     """lit le fichier de configuration"""
     cfg = read_conf(self.CONF_FILE)
     self.open_last_date = cfg['open']['last_date']
     self.open_next_date = cfg['open']['next_date']
     self.close_last_date = cfg['close']['last_date']
     self.close_next_date = cfg['close']['next_date']
Example #3
0
 def read_config(self):
     """lit le fichier de configuration"""
     cfg = read_conf(self.CONF_FILE)
     self.api_key = cfg["ALERT_API_KEY"]
     self.title = cfg["APP_NAME"]
     if type(cfg["alertes"]) is dict:
         self.alertes = cfg["alertes"]
     else:
         self.alertes = dict()
Example #4
0
 def read_config(self):
     """lit le fichier de configuration"""
     cfg = read_conf(self.CONF_FILE)
     self.open_last_date = cfg['open']['last_date']
     self.open_next_date = cfg['open']['next_date']
     self.close_last_date = cfg['close']['last_date']
     self.close_next_date = cfg['close']['next_date']
     self.pin_bas = cfg['PIN_BAS']
     self.pin_haut = cfg['PIN_HAUT']
     self.pin_enable = cfg['PIN_ENABLE']
     self.pin_in_1 = cfg['PIN_IN_1']
     self.pin_in_2 = cfg['PIN_IN_2']
Example #5
0
 def read_config(self):
     """lit le fichier de configuration"""
     cfg = read_conf(self.CONF_FILE)
     self.last_capture = cfg['last_capture']
Example #6
0

if __name__ == "__main__":

    if len(sys.argv) > 1:
        # porte à actionner
        action = sys.argv[1]

        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)

        porte = PorteDC()
        luminosite = Luminosite()

        # ephemeride sur la localisation du poulailler
        CFG = read_conf("global")
        s = Sun(lat=CFG['LATITUDE'], long=CFG['LONGITUDE'])

        if should_open(action):
            if is_lumi_open(luminosite.read_level, luminosite.seuil_ouverture):
                ouverture_porte()
                # prochain lever de soleil
                print("Definition du prochain lever de soleil...")
                d_sunrise = datetime.now(tzlocal())
                next_sunrise = s.sunrise(d_sunrise)
                if next_sunrise < d_sunrise.time():
                    d_sunrise = d_sunrise + timedelta(days=1)
                    next_sunrise = s.sunrise(d_sunrise)
                next_date = datetime.combine(d_sunrise.date(), next_sunrise)
                porte.open_next_date = next_date.strftime("%Y-%m-%d %H:%M:%S")
            else: