mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Fixes London Air parsing error (#97557)
This commit is contained in:
parent
7e134a3d44
commit
3f5c0a1285
@ -218,10 +218,12 @@ def parse_api_response(response):
|
||||
for authority in AUTHORITIES:
|
||||
for entry in response["HourlyAirQualityIndex"]["LocalAuthority"]:
|
||||
if entry["@LocalAuthorityName"] == authority:
|
||||
if isinstance(entry["Site"], dict):
|
||||
entry_sites_data = [entry["Site"]]
|
||||
else:
|
||||
entry_sites_data = entry["Site"]
|
||||
entry_sites_data = []
|
||||
if "Site" in entry:
|
||||
if isinstance(entry["Site"], dict):
|
||||
entry_sites_data = [entry["Site"]]
|
||||
else:
|
||||
entry_sites_data = entry["Site"]
|
||||
|
||||
data[authority] = parse_site(entry_sites_data)
|
||||
|
||||
|
8
tests/fixtures/london_air.json
vendored
8
tests/fixtures/london_air.json
vendored
@ -3,6 +3,14 @@
|
||||
"@GroupName": "London",
|
||||
"@TimeToLive": "38",
|
||||
"LocalAuthority": [
|
||||
{
|
||||
"@LocalAuthorityCode": "7",
|
||||
"@LocalAuthorityName": "City of London",
|
||||
"@LaCentreLatitude": "51.51333",
|
||||
"@LaCentreLongitude": "-0.088947",
|
||||
"@LaCentreLatitudeWGS84": "6712603.132989",
|
||||
"@LaCentreLongitudeWGS84": "-9901.534748"
|
||||
},
|
||||
{
|
||||
"@LocalAuthorityCode": "24",
|
||||
"@LocalAuthorityName": "Merton",
|
||||
|
Loading…
x
Reference in New Issue
Block a user