Exemplo n.º 1
0
 def GET(self):
     nest = Nest(username=SETTINGS.get("nest", "user"),
                 password=SETTINGS.get("nest", "pwd"))
     nest.login()
     nest.read_status()
     #nest.status["shared"].itervalues().next()
     return json.dumps(nest.status["shared"].itervalues().next())
Exemplo n.º 2
0
 def GET(self):
     nest = Nest(username=SETTINGS.get("nest", "user"),
                 password=SETTINGS.get("nest", "pwd"))
     nest.login()
     nest.read_status()        
     temperature = nest.status["shared"].itervalues().next()["current_temperature"]
     humidity = nest.status["device"].itervalues().next()["current_humidity"]
     return json.dumps({"temperature": external.convert_to_fahrenheit(temperature), "humidity": humidity})
Exemplo n.º 3
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)
Exemplo n.º 4
0
 def PUT(self, state):
     nest = Nest(username=SETTINGS.get("nest", "user"),
                 password=SETTINGS.get("nest", "pwd"))
     nest.login()
     nest.read_status()
     nest.set_away(state)
Exemplo n.º 5
0
 def GET(self):
     nest = Nest(username=SETTINGS.get("nest", "user"),
                 password=SETTINGS.get("nest", "pwd"))
     nest.login()
     nest.read_status()        
     return json.dumps(nest.away())