v.0.4.7 mock_weather_data return as json
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
import time
|
||||
import network
|
||||
import urequests
|
||||
import network # type: ignore
|
||||
import urequests # type: ignore
|
||||
from ..classes.location import Location
|
||||
from ..classes.weather import CurrentCondition, Weather
|
||||
import json
|
||||
|
||||
API_KEY = '3545ce42d0ba436e8dc164532250410'
|
||||
ACTUAL_WEATHER = 'https://api.weatherapi.com/v1/current.json?key={{key}}&q={{city}}&aqi=yes'
|
||||
|
||||
|
||||
ACTUAL_WEATHER_URL = 'http://api.weatherapi.com/v1/current.json?key={API_KEY}&q={city}&aqi=yes&lang={lang}'
|
||||
class Wlan:
|
||||
def __init__(self, ssid, password):
|
||||
self.ssid = ssid
|
||||
@@ -73,6 +71,7 @@ class Wlan:
|
||||
}
|
||||
}
|
||||
}"""
|
||||
return json.loads(data)
|
||||
|
||||
filepath = 'restapi/mock-weather.json'
|
||||
try:
|
||||
@@ -100,9 +99,7 @@ class Wlan:
|
||||
print('connected! IP=', wlan.ifconfig()[0])
|
||||
|
||||
def actual_weather(self, city='grosshansdorf', lang='de', test_mode=False) -> Weather:
|
||||
weather_url = (
|
||||
f'https://api.weatherapi.com/v1/current.json?key={API_KEY}&q={city}&aqi=yes&lang={lang}'
|
||||
)
|
||||
weather_url = ACTUAL_WEATHER_URL.format(API_KEY=API_KEY, city=city, lang=lang)
|
||||
|
||||
if not test_mode:
|
||||
self.connect()
|
||||
|
||||
Reference in New Issue
Block a user