From a31de845789da5df63a83f4cd2a68f86e497ac42 Mon Sep 17 00:00:00 2001 From: Cryson Date: Wed, 19 Jul 2017 13:48:37 -0400 Subject: [PATCH] Fixing bug in wunderground where it'd return null --- ecobee/ecobee.py | 2 +- main.py | 2 +- wunderground/wunderground.py | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ecobee/ecobee.py b/ecobee/ecobee.py index 94c4511..085c9d0 100644 --- a/ecobee/ecobee.py +++ b/ecobee/ecobee.py @@ -4,7 +4,7 @@ import sys import time -logging.basicConfig(filename='log/hydrogen.log', level=logging.DEBUG) +logging.basicConfig(filename='log/hydrogen.log', level=logging.INFO) with open('ecobee/data/ecobee_secret.json') as data_file: data = json.load(data_file) diff --git a/main.py b/main.py index 0df7829..1283dd5 100755 --- a/main.py +++ b/main.py @@ -12,7 +12,7 @@ from hydrogen import hydrogen from wunderground import wunderground -logging.basicConfig(filename='log/hydrogen.log', level=logging.DEBUG) +logging.basicConfig(filename='log/hydrogen.log', level=logging.INFO) # Set your ecobee index list thermostatlist = [0, 1] diff --git a/wunderground/wunderground.py b/wunderground/wunderground.py index 4546fcc..d7fbd11 100644 --- a/wunderground/wunderground.py +++ b/wunderground/wunderground.py @@ -49,6 +49,9 @@ def pull_weather_json(): humidity = float(humidity) feels_like = float(w['current_observation']['feelslike_f']) dewpoint = float(w['current_observation']['dewpoint_f']) + + if 'current_observation' not in w: + logging.info("weather json isn't normal") with open('wunderground/cache/wunderground.cache', 'w') as data_file: data_file.write('%s' % currenttemp) @@ -58,11 +61,11 @@ def pull_weather_json(): def get_current_temperature(): minutes = checkcache_mtime() - if minutes > 30: + if minutes >= 30: logging.info("Pulling new outside temperature") temp = pull_weather_json() return temp - elif minutes < 30: + elif minutes <= 29: logging.info("Using cached outside temperature, as old temp isn't 30 minutes old") with open('wunderground/cache/wunderground.cache', 'r') as data_file: temp = data_file.read()