Exemplo n.º 1
0
        if now_time >= time(01, 00) and now_time < time(02, 00):
            #Start subprocess if irrigation hasn't been done yet
            if nirrigated == 0:
                print("Time for some irrigation!")
                try:

                    if relay_proc is not None and relay_proc.poll() is None:
                        print('process is already running')
                    else:
                        relay_proc = subprocess.Popen(
                            ['/home/pi/GardenBrain/relay.py'],
                            stdout=subprocess.PIPE,
                            stderr=subprocess.STDOUT)
                        dolog(
                            "Main.py - Successfully started the relay.py script"
                        )

                    #Sleeping for a second
                    t.sleep(1)

                except:
                    print("Starting night time irrigation script failed")
                    dolog("Main.py - Starting the relay.py script failed")

        elif now_time >= time(16, 00) and now_time < time(17, 00):
            #Start subprocess if irrigation hasn't been done yet
            if dirrigated == 0:
                print("Perhaps some extra irrigation?")
                try:
Exemplo n.º 2
0
resetall = 0

if resetall == 1:
    #Connecting to database and creating the tables needed, and dropping existing ones if there already
    dbdroptable('weather_data')
    dbdroptable('weather_settings')
    dbcreatewstables()
    dbcreatewdtables()
    db_ws_insert('0', '0', '0', '0', '0', '0', '0', '0', '0')

#Running the Main script which analyzes the data and sets irrigation timer accordingly
try:
    subprocess.Popen(['/home/pi/GardenBrain/main.py'],
                     stdout=subprocess.PIPE,
                     stderr=subprocess.STDOUT)
    dolog("Weather.py - Starting main GardenBrain script succeeded")
    time.sleep(1)

except:
    dolog("Weather.py - Starting main GardenBrain script failed")

#Starting analyzer script in the background which updates the weather_settings table with accurate irrigation times
try:
    subprocess.Popen(['/home/pi/GardenBrain/analyzer.py'],
                     stdout=subprocess.PIPE,
                     stderr=subprocess.STDOUT)
    dolog("Weather.py - Starting analyzer script succeeded")
    time.sleep(1)

except:
    dolog("Weather.py - Starting analyzer script failed")
Exemplo n.º 3
0
# Import required Python libraries
import time as t
from datetime import datetime, time
from functions import dbfetch,dbupdate,relay_delay,relay_manual,dolog

#Checking to see what time it is for the following functions
now = datetime.now()
now_time = now.time()

#Sleeping for a moment
t.sleep(15)

#Getting data for the delay variable which determines how long the relay stays open
if now_time >= time(01,00) and now_time <= time(02,00):
    delay = dbfetch('NIGHT_SECONDS','weather_settings')
    dolog("NIGHT_SECONDS received from database in relay.py :")
    dolog(delay)
elif now_time >= time(16,00) and now_time <= time(17,00):
    delay = dbfetch('DAY_EXTRA','weather_settings')
    dolog("DAY_EXTRA received from database in relay.py :")
    dolog(delay)
else:
    #Setting delay to a default 60 seconds if the script is run outside of the set timeframes
    delay = 60

#If delay variable is not 0
if delay != 0:
    
    #Starting the delay
    relay_manual('on')
Exemplo n.º 4
0
# Import required Python libraries
import time as t
from datetime import datetime, time
from functions import dbfetch, dbupdate, relay_delay, relay_manual, dolog

#Checking to see what time it is for the following functions
now = datetime.now()
now_time = now.time()

#Sleeping for a moment
t.sleep(15)

#Getting data for the delay variable which determines how long the relay stays open
if now_time >= time(01, 00) and now_time <= time(02, 00):
    delay = dbfetch('NIGHT_SECONDS', 'weather_settings')
    dolog("Relay.py - NIGHT_SECONDS received from database :")
    dolog(delay)
elif now_time >= time(16, 00) and now_time <= time(17, 00):
    delay = dbfetch('DAY_EXTRA', 'weather_settings')
    dolog("Relay.py - DAY_EXTRA received from database :")
    dolog(delay)
else:
    #Setting delay to a default 60 seconds if the script is run outside of the set timeframes
    delay = 60

#If delay variable is not 0
if delay != 0:

    #Starting the delay
    relay_manual('on')
Exemplo n.º 5
0
            #Start subprocess if irrigation hasn't been done yet
            if nirrigated == 0:
                print("Time for some irrigation!")
                try:
                    # Old part that was buggy
                    # p = subprocess.Popen(['/home/pi/GardenBrain/relay.py'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

                    if relay_proc is not None and relay_proc.poll() is None:
                        print('process is already running')
                    else:
                        relay_proc = subprocess.Popen(
                            ['/home/pi/GardenBrain/relay.py'],
                            stdout=subprocess.PIPE,
                            stderr=subprocess.STDOUT)
                        dolog(
                            "Main.py - Successfully started the relay.py script"
                        )

                    #Sleeping for a second
                    t.sleep(1)

                except:
                    print("Starting night time irrigation script failed")
                    dolog("Main.py - Starting the relay.py script failed")

        elif now_time >= time(16, 00) and now_time < time(17, 00):
            #Start subprocess if irrigation hasn't been done yet
            if dirrigated == 0:
                print("Perhaps some extra irrigation?")
                try:
                    # Old part that was buggy
Exemplo n.º 6
0
#Sleeping for 2 seconds
t.sleep(2)

#Loading the JSON config file
config = json.loads(open('/var/www/html/config.json').read())

try:

    #This script should be on a loop running once every 15 minutes or so
    while True:

        #Start with collecting the data for the last 15 minutes
        temperature = minutedata('TEMPERATURE')
        humidity = minutedata('HUMIDITY')
        pressure = minutedata('PRESSURE')
        dolog("Analyzer.py - Weather data received from database")

        #Sleeping for a second
        t.sleep(1)

        #Get the average temperature, humidity and pressure for those 15 minutes
        temp_average = averager(temperature)
        humid_average = averager(humidity)
        press_average = averager(pressure)
        dolog("Analyzer.py - Weather data averaged")

        #Sleeping for a second
        t.sleep(1)

        #Read database if irrigation has been done and if so, then make sure the minutes number is reset to 0
        nighti = dbfetch('NIGHT_IRRIGATED', 'weather_settings')