added config prefix
This commit is contained in:
@@ -17,7 +17,7 @@ else:
|
||||
|
||||
# Try to grab a sensor reading. Use the read_retry method which will retry up
|
||||
# to 15 times to get a sensor reading (waiting 2 seconds between each retry).
|
||||
humidity, temperature = Adafruit_DHT.read_retry(SENSOR_TYPE, GPIO_PIN_DHT)
|
||||
humidity, temperature = Adafruit_DHT.read_retry(SENSOR_TYPE, config.GPIO_PIN_DHT)
|
||||
|
||||
# Un-comment the line below to convert the temperature to Fahrenheit.
|
||||
# temperature = temperature * 9/5.0 + 32
|
||||
@@ -27,7 +27,7 @@ humidity, temperature = Adafruit_DHT.read_retry(SENSOR_TYPE, GPIO_PIN_DHT)
|
||||
# guarantee the timing of calls to read the sensor).
|
||||
# If this happens try again!
|
||||
if temperature is not None and humidity is not None:
|
||||
response = requests.post(SENSORDATA_URL, json={"owner": owner, "temperatureValue": temperature, "humidityValue":humidity})
|
||||
response = requests.post(config.SENSORDATA_URL, json={"owner": owner, "temperatureValue": temperature, "humidityValue":humidity})
|
||||
print 'Temp={0:0.1f}*C'.format(temperature)
|
||||
print 'Humidity={0:0.1f}%'.format(humidity)
|
||||
if response.status_code != 200:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
import config
|
||||
|
||||
def sync():
|
||||
server = Server(API_BASE_URL, CONTROLLER_ID)
|
||||
local = File(STATE_FILE)
|
||||
server = Server(config.API_BASE_URL, config.CONTROLLER_ID)
|
||||
local = File(config.STATE_FILE)
|
||||
server_state = server.get_state()
|
||||
|
||||
if local.present():
|
||||
|
||||
@@ -7,7 +7,7 @@ class Changer(object):
|
||||
self.local_state = local_state
|
||||
self.remote_state = remote_state
|
||||
GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme
|
||||
GPIO.setup(GPIO_PIN_VALVE, GPIO.OUT)
|
||||
GPIO.setup(config.GPIO_PIN_VALVE, GPIO.OUT)
|
||||
|
||||
self.states = {
|
||||
'opening': self.open_valve,
|
||||
@@ -26,11 +26,11 @@ class Changer(object):
|
||||
return self.local_state
|
||||
|
||||
def open_valve():
|
||||
GPIO.output(GPIO_PIN_VALVE, GPIO.HIGH)
|
||||
GPIO.output(config.GPIO_PIN_VALVE, GPIO.HIGH)
|
||||
self.local_state['out_valve'] = 'open'
|
||||
|
||||
def close_valve():
|
||||
GPIO.output(GPIO_PIN_VALVE, GPIO.LOW)
|
||||
GPIO.output(config.GPIO_PIN_VALVE, GPIO.LOW)
|
||||
self.local_state['out_valve'] = 'closed'
|
||||
|
||||
def validate_states(self):
|
||||
|
||||
Reference in New Issue
Block a user