thank you in advance for reading and taking the time to troubleshoot this with me!

Let me first start off with the important stuff:

Target Device:

* Raspberry Pi 4B
* Electronic-Salon Relay Hat

Development Environment:

* macOS Catalina
* PyCharm
* Python 2.7.10

At my home I have a spring that serves my home with water. The solution I came up with to prevent dirty water caused by bad rainy weather loosening up the ground soil from entering my cistern is closing a valve and waiting for about 12 hours for the water to clear back up. Then I open the valve and clear water flows into my cistern providing my home with water, and that solution works really well.

I recently came up with the conclusion that I want to automate this process with a normally open solenoid. I purchased a Raspberry Pi, a Relay Hat, and an Ambient Weather weather station.

What I'm looking to do with Python 2.7.10 is check the same variable against itself after an allotted time. In this example, I'm checking the relative barometric pressure against itself and I'm wanting to look for a significant negative change in that variable.

i.e "What does variable A have? Okay, now wait 3 seconds. What does A have now? How much has it changed?"

This is what I've bodged together so far, how can I improve? Thank you.

At first I was thinking maybe I should plot a chart with the data and compare the difference between the two plot points, but I wasn't sure how to use Matplotlib.

```
# This is the executing script for the Smart Valve.
# This project is powered by raspberry pi and 120 angry pixies.
import time,imp
from ambient_api.ambientapi import AmbientAPI

# This code will pull the data from the weather computer

api = AmbientAPI()
devices = api.get_devices()
device = devices[0]
time.sleep(1) #pause for a second to avoid API limits

# The code below is meant for telling the python interpreter to behave normally whether or not it's in a RPi env or a
# developer env

try:
    imp.find_module('RPi.GPIO')
    import RPi.GPIO as GPIO
except ImportError:
    """
    import FakeRPi.GPIO as GPIO
    OR
    import FakeRPi.RPiO as RPiO
    """

    import FakeRPi.GPIO as GPIO

# this code compares the rate of change for the barometric pressure over time and checks if rate is negative
a1 = None
a2 = None

while True:
    weatherData = device.get_data()
    data = dict(weatherData[0])
    pressure = data[u'baromrelin']
    wind = data[u'windspeedmph']
    rain = data[u'hourlyrainin']
    a1 = pressure
    time.sleep(30)
    a2 = pressure
    print("A1 is equal to " + str(a1))
    print("A2 is equal to " + str(a2))
    if a1 > a2:
        print("we should close the valve, it'll rain soon")
        continue
    elif a1 == a2:
        print("It's all hunky dory up here!")
        break

```