def callback(channel): if GPIO.input(channel): print "LED off" lcd = Lcd() lcd.clear() lcd.display_string(message_need_water, 1) savedata(1, "Need water") else: print "LED on" lcd = Lcd() lcd.clear() lcd.display_string(message_noneed_water, 1) savedata(1, "No need water")
def pumpswitchOn(request): #lcd = Lcd() #lcd.clear() #lcd.display_string("pump on",1) #relay = Relay() #relay.switch(3,1) lcd = Lcd() lcd.clear() pumpStatus = "ON" lcd.display_string("Water Pump %s" % pumpStatus, 1) moistureLevel = getLatestMoistureLevel() savedata(1, moistureLevel, pumpStatus) response_mesage = {"result": "pump is on"} return JsonResponse(response_mesage)