From 3c5404a3daad5749b16f98a6775fd27286a66156 Mon Sep 17 00:00:00 2001 From: Mike Cifelli <1836280-mike-cifelli@users.noreply.gitlab.com> Date: Thu, 5 Jan 2023 19:18:11 -0500 Subject: [PATCH] Call new temperature endpoint --- chutney/weather/weather_updater.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/chutney/weather/weather_updater.py b/chutney/weather/weather_updater.py index ccb2af1..bf92f9a 100644 --- a/chutney/weather/weather_updater.py +++ b/chutney/weather/weather_updater.py @@ -15,7 +15,7 @@ class WeatherUpdater: lat = config['weather'].get('lat') lon = config['weather'].get('lon') - self.uri = f'https://{host}/api/weather?lat={lat}&lon={lon}&units=metric' + self.uri = f'https://{host}/api/temperature?lat={lat}&lon={lon}&units=metric' self.auth = (user, password) self.weatherTempFile = 'data/weather.tmp' self.weatherFile = 'data/weather.txt' @@ -33,18 +33,7 @@ class WeatherUpdater: self.persistTemperature('halted') def getTemperature(self): - weather = self.getWeather() - currentWeather = list( - filter( - lambda t: t['timestep'] == 'current', - weather['tomorrow']['data']['timelines'] - ) - ) - - return currentWeather[0]['intervals'][0]['values']['temperature'] - - def getWeather(self): - return requests.get(self.uri, auth=self.auth, timeout=3).json() + return requests.get(self.uri, auth=self.auth, timeout=3).json()['temperature'] def persistTemperature(self, temperature): with open(self.weatherTempFile, 'w') as file: