summaryrefslogtreecommitdiff
path: root/cached
diff options
context:
space:
mode:
authorScott <[email protected]>2022-01-06 12:13:34 -0800
committerScott <[email protected]>2022-01-06 12:13:34 -0800
commit5f75cf834725ac26b289cc5f157af0cb71cd5f0e (patch)
treef31baf4247a7d29eb1457a74f75d373d10539237 /cached
parentba223f821df1e9b8abbb6f6d23d5ba92c5a70b05 (diff)
A bunch of changes...
Diffstat (limited to 'cached')
-rw-r--r--cached/weather_forecast.py22
1 files changed, 5 insertions, 17 deletions
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(