Esempio n. 1
0
def setThermostatFanMode(iden):
    new_mode = request.query.mode
    try:
        if new_mode == "auto" or new_mode == "off":
            homeThermostats[iden].fanMode = new_mode
        else:
            return ThermostatError(
                400, "Fan mode \"{}\" is invalid.".format(new_mode)).toJSON()
        return homeThermostats[iden].toJSON()
    except KeyError:
        return ThermostatError(
            404, "Thermostat with id \"{}\" is not found in this home.".format(
                iden)).toJSON()
Esempio n. 2
0
def setThermostatHeatPoint(iden):
    new_point = float(request.query.heatPoint)
    try:
        if new_point < 100 and new_point > 30:
            homeThermostats[iden].heatSetPoint = new_point
        else:
            return ThermostatError(
                400, "Heat point: {} is invalid.".format(new_point)).toJSON()
        return homeThermostats[iden].toJSON()
    except KeyError:
        return ThermostatError(
            404, "Thermostat with id: {} is not found in this home.".format(
                iden)).toJSON()
Esempio n. 3
0
def setThermostatOperationMode(iden):
    new_mode = request.query.mode
    try:
        if new_mode == "cool" or new_mode == "heat" or new_mode == "off":
            homeThermostats[iden].operationMode = new_mode
        else:
            return ThermostatError(
                400,
                "Operation mode: {} is invalid.".format(new_mode)).toJSON()
        return homeThermostats[iden].toJSON()
    except KeyError:
        return ThermostatError(
            404, "Thermostat with id: {} is not found in this home.".format(
                iden)).toJSON()
Esempio n. 4
0
def getThermostatName(iden):
    try:
        return homeThermostats[iden].name
    except KeyError:
        return ThermostatError(
            404, "Thermostat with id: {} is not found in this home.".format(
                iden)).toJSON()
Esempio n. 5
0
def getThermostatHeatPoint(iden):
    try:
        return str(homeThermostats[iden].heatSetPoint)
    except KeyError:
        return ThermostatError(
            404, "Thermostat with id: {} is not found in this home.".format(
                iden)).toJSON()
Esempio n. 6
0
def getThermostatCurrentTemp(iden):
    try:
        print(homeThermostats[iden].currentTemp)
        return str(homeThermostats[iden].currentTemp)
    except KeyError:
        return ThermostatError(
            404, "Thermostat with id: {} is not found in this home.".format(
                iden)).toJSON()
Esempio n. 7
0
def setThermostatName(iden):
    new_name = request.query.name
    try:
        homeThermostats[iden].name = new_name
        return homeThermostats[iden].toJSON()
    except KeyError:
        return ThermostatError(
            404, "Thermostat with id: {} is not found in this home.".format(
                iden)).toJSON()
Esempio n. 8
0
def error500(error):
    return ThermostatError(500, error.body).toJSON()
Esempio n. 9
0
def error404(error):
    return ThermostatError(404, error.body).toJSON()