Example #1
0
def start_cycle(cycle_id, cycle_durations):
    """
    Opens a irrigation value for the cycle duration
    """
    update_status("Running Cycle")
    logging.debug("Starting Cycle: %s", cycle_id)
    date = datetime.now()
    add_cycle(cycle_id, date, str(cycle_durations))
    zone = 1
    for duration in cycle_durations:
        run_cycle(zone, duration)
        zone += 1
    
    # Be sure all zones are closed
    sprinkler_end_cycle()
    update_status("Finished Cycle")
    logging.debug("Finished Cycle: %s", cycle_id)
Example #2
0
def update_from_weather(cycle_id, cycle_durations, station_number, api_key):
    """
    Check the current weather conditions.  Update status if a weather event should stop
    the cycle.
    """

    # Get current weather
    weather = read_weather(station_number, api_key)
    
    # Turn off if too windy
    if wind_speed(weather) > 10:
        update_status("Canceled: Wind")
        logging.info("Skipping Cycle: %s Too Windy: %s MPH", cycle_id, wind_speed(weather))
        return [0 for unused in cycle_durations]
    
    # Turn off if humidity is too high
    if humidity(weather) > 90:
        update_status("Canceled: Humidity")
        logging.info("Skipping Cycle: %s Humidity too high: %s", cycle_id, humidity(weather))
        return [0 for unused in cycle_durations]

    # Reduce if rainfall in last 24 hours
    if current_rain(weather) > 0:
        update_status("Canceled: Rain")
        logging.info("Skipping Cycle: %s 3 hour rainfall: %s", cycle_id, current_rain(weather))
        return [0 for unused in cycle_durations]    
    
    return cycle_durations