Exemple #1
0
def index():
    global wificon
    if wiredin.current()!=None:wificon = "wifi"
    else:wificon="wifi_off"
    temp = usbtemper.findtemp()
    hum = usbtemper.findhum()
    return render_template('index.html', led = led, outlet1 = outlet1, outlet2 = outlet2, outlet3 = outlet3, outlet4 = outlet4, temp = temp, hum = hum, **jinjavar)
Exemple #2
0
def update_check():

    # check to see if we have wifi, and refresh worker if need be
    wifiguy = WirelessUser.objects.get(pk=1)

    # Get the garden and find the stats
    garden = Garden.objects.get(pk=3)
    garden.current_temp = usbtemper.findtemp()
    garden.current_humidity = usbtemper.findhum()

    # Double check highs and lows for data

    garden.current_temp = int(garden.current_temp)
    garden.current_humidity = int(garden.current_humidity)
    if garden.current_temp > garden.temp_high_today:
        garden.temp_high_today = garden.current_temp
    if garden.current_temp < garden.temp_low_today or garden.temp_low_today == 0:
        garden.temp_low_today = garden.current_temp
    if garden.current_humidity > garden.humidity_high_today:
        garden.humidity_high_today = garden.current_humidity
    if garden.current_humidity < garden.humidity_low_today or garden.humidity_low_today == 0:
        garden.humidity_low_today = garden.current_humidity

    garden.save()

    print('-----------------------THIS IS AN UPDATE-----------------------')
    print(garden.current_temp)
    print(garden.current_humidity)
    #Here comes each potential outlet.
    for x in range(1, 6):
        outlet_check(x)

    wifiguy.wifi_check()
Exemple #3
0
def checker():
    global temp
    global hum
    temp = usbtemper.findtemp()
    hum = usbtemper.findhum()
    for x in range(1,6):
        mustard = oselect(x)
        mustard.update(temp,hum,led.check())
def checker():
    global temp
    global hum
    temp = usbtemper.findtemp()
    hum = usbtemper.findhum()
    socketio.emit('temp', str(temp))
    socketio.emit('hum', str(hum))
    for x in range(1, 6):
        mustard = oselect(x)
        mustard.update(temp, hum, led.check())
        socketio.emit(str(mustard.num) + 'switch', mustard.phrase())
def garden():
    #camera stuff, we'll fix later!
    temp = usbtemper.findtemp()
    hum = usbtemper.findhum()
    return render_template('garden.html', temp=temp, hum=hum, **jinjavar)
#def create_app():
app = Flask(__name__)
app.config['SECRET_KEY'] = 'mysecret'
socketio = SocketIO(app)
#    return app

#create some globals for wireless stuff and outlet to pass outletname
wiredin = Wireless()
global jinjavar
global outlet
global temp
global hum

temp = usbtemper.findtemp()
hum = usbtemper.findhum()


#find wlan0 output link for wireless access
def wlan():
    if wiredin.current() != None:
        gw = os.popen("ip -4 route show default").read().split()
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect((gw[2], 0))
        ipaddr = s.getsockname()[0]
        return str("url: " + ipaddr + ":5000")
    else:
        return str("None")


#Find the correct wifi icon