File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,22 +112,19 @@ def handle_pump(command):
112112 """
113113 pump_time = command ['pump_time' ]
114114 pump_status = command ['pump' ]
115- if pump_status == 0 :
116- print ("Turning pump off" )
117- water_pump .value = False
118- else :
119- print ("Turning pump on for {} seconds..." , pump_time )
115+ if pump_status == 1 :
116+ print ("Turning pump on for {} seconds..." .format (pump_time ))
120117 start_pump = time .monotonic ()
121118 while True :
122119 now = time .monotonic ()
123120 if now - start_pump > pump_time :
124- # Turn the pump off
125- print ("Turning pump off" )
126- water_pump .value = False
121+ # Timer expired, leave the loop
122+ print ("Plant watered!" )
127123 break
128124 else :
129125 initial = now
130- print ("pump off" )
126+ print ("Turning pump off" )
127+ water_pump .value = False
131128
132129# Initialize Google Cloud IoT Core interface
133130google_iot = Cloud_Core (esp , secrets )
You can’t perform that action at this time.
0 commit comments