Esempio n. 1
0
def service():
    """
    Main loop waiting for a cycle_window to become valid
    """
    logging.debug('Service Started')
    while True:
        try:
            logging.debug("Service woke up")
            cycle_id, cycle_durations = in_schedule()
            if cycle_id:
                cycle_durations = update_from_weather(cycle_id, cycle_durations,
                                                      station_number=SETTINGS.get("weather", "station"),
                                                      api_key=SETTINGS.get("weather", "api_key"))
                
                logging.debug("Cycle Id: %s Duration: %s", cycle_id, cycle_durations)
                start_cycle(cycle_id, cycle_durations)
            else:
                record_data()
                sleep(60*15)  # 15 minutes
                
        except Exception, ex:
            logging.exception(ex)
Esempio n. 2
0
 def PUT(self):
     record_data(nest_user=SETTINGS.get("nest", "user"),
                 nest_password=SETTINGS.get("nest", "pwd"),
                 weather_station=SETTINGS.get("weather", "station"))