mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 07:47:08 +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 authority in AUTHORITIES:
|
||||||
for entry in response["HourlyAirQualityIndex"]["LocalAuthority"]:
|
for entry in response["HourlyAirQualityIndex"]["LocalAuthority"]:
|
||||||
if entry["@LocalAuthorityName"] == authority:
|
if entry["@LocalAuthorityName"] == authority:
|
||||||
if isinstance(entry["Site"], dict):
|
entry_sites_data = []
|
||||||
entry_sites_data = [entry["Site"]]
|
if "Site" in entry:
|
||||||
else:
|
if isinstance(entry["Site"], dict):
|
||||||
entry_sites_data = entry["Site"]
|
entry_sites_data = [entry["Site"]]
|
||||||
|
else:
|
||||||
|
entry_sites_data = entry["Site"]
|
||||||
|
|
||||||
data[authority] = parse_site(entry_sites_data)
|
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",
|
"@GroupName": "London",
|
||||||
"@TimeToLive": "38",
|
"@TimeToLive": "38",
|
||||||
"LocalAuthority": [
|
"LocalAuthority": [
|
||||||
|
{
|
||||||
|
"@LocalAuthorityCode": "7",
|
||||||
|
"@LocalAuthorityName": "City of London",
|
||||||
|
"@LaCentreLatitude": "51.51333",
|
||||||
|
"@LaCentreLongitude": "-0.088947",
|
||||||
|
"@LaCentreLatitudeWGS84": "6712603.132989",
|
||||||
|
"@LaCentreLongitudeWGS84": "-9901.534748"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"@LocalAuthorityCode": "24",
|
"@LocalAuthorityCode": "24",
|
||||||
"@LocalAuthorityName": "Merton",
|
"@LocalAuthorityName": "Merton",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user