Exemple #1
0
#Starts with door closed
GPIO.output(D_button_pin, GPIO.HIGH)


def main():
    #Starts on off state
    currentState = "off"
    while True:
        #Reads all sensors
        states.readSensors()

        #Checks control state
        if states.current_in_temp >= states.min_temp and states.current_in_temp <= states.max_temp:
            currentState = "off"
        elif states.current_in_temp < states.min_temp:
            currentState = "heating"
        elif states.current_in_temp > states.max_temp:
            currentState = "cooling"

        #Sends control state to air conditioner
        states.sendAirCondCommand(currentState)

        if GPIO.input(F_button_pin) == GPIO.LOW:
            break
        time.sleep(0.5)


if __name__ == "__main__":
    main()
    states.stop()