Call new temperature endpoint
This commit is contained in:
parent
627420e9cb
commit
3c5404a3da
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue