예제 #1
0
def wait_for_cycle():
    """
    A cycle is running.  Loop while we are in that cycle.
    """
    # Check cycle_milliseconds
    while int(sprinkler_state()["cycle_milliseconds"]) > 0:
        sleep(15)
예제 #2
0
def record_data(nest_user, nest_password, weather_station):
    """
    Collect the data and send it to the database
    """

    weather = read_weather(weather_station)
    nest = Nest(nest_user, nest_password)
    nest.login()
    nest.read_status()

    irrigation_state = sprinkler_state()
    alarm_zones = get_zone_state()

    data = {
        "entryDate": datetime.now(),
        "irrigation_zone1": irrigation_state["zone1"],
        "irrigation_zone2": irrigation_state["zone2"],
        "irrigation_zone3": irrigation_state["zone3"],
        "irrigation_zone4": irrigation_state["zone4"],
        "alarm_zone1": alarm_zones["zone1"],
        "alarm_zone2": alarm_zones["zone2"],
        "alarm_zone3": alarm_zones["zone3"],
        "alarm_zone4": alarm_zones["zone4"],
        "alarm_zone5": alarm_zones["zone5"],
        "alarm_zone6": alarm_zones["zone6"],
        "alarm_zone7": alarm_zones["zone7"],
        "alarm_zone8": alarm_zones["zone8"],
        "alarm_zone9": alarm_zones["zone9"],
        "outside_temp": temperature(weather),
        "outside_humidity": humidity(weather),
        "rainfall": current_rain(weather),
        "wind_speed": wind_speed(weather),
    }

    data.update(nest.history_states())
    update_history(data)
예제 #3
0
 def GET(self):
     return json.dumps(sprinkler.sprinkler_state(host=SETTINGS.get("irrigation", "irrigation_host"),
                                                 port=SETTINGS.get("irrigation", "irrigation_port")))