From 5f75cf834725ac26b289cc5f157af0cb71cd5f0e Mon Sep 17 00:00:00 2001 From: Scott Date: Thu, 6 Jan 2022 12:13:34 -0800 Subject: A bunch of changes... --- cached/weather_forecast.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'cached') diff --git a/cached/weather_forecast.py b/cached/weather_forecast.py index d1e7540..b343938 100644 --- a/cached/weather_forecast.py +++ b/cached/weather_forecast.py @@ -19,6 +19,8 @@ import datetime_utils import dateparse.dateparse_utils as dp import persistent import text_utils +import smart_home.thermometers as temps + logger = logging.getLogger(__name__) @@ -61,23 +63,9 @@ class CachedDetailedWeatherForecast(persistent.Persistent): self.forecasts = {} # Ask the raspberry pi about the outside temperature. - www = None - try: - www = urllib.request.urlopen( - "http://10.0.0.75/~pi/outside_temp", - timeout=2, - ) - current_temp = www.read().decode("utf-8") - current_temp = float(current_temp) - current_temp *= (9/5) - current_temp += 32.0 - current_temp = round(current_temp) - except Exception: - logger.warning('Timed out reading 10.0.0.75/~pi/outside_temp?!') - current_temp = None - finally: - if www is not None: - www.close() + current_temp = temps.ThermometerRegistry().read_temperature( + 'house_outside', convert_to_fahrenheit=True + ) # Get a weather forecast for Bellevue. www = urllib.request.urlopen( -- cgit v1.3