Skip to content

Commit da1367c

Browse files
authored
fix: for devices missing expected api attributes (#50)
1 parent 768f572 commit da1367c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/blueair_api/device.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ async def create_device(cls, api, uuid, name, mac, refresh=False):
2020
uuid=uuid,
2121
name=name,
2222
mac=mac,
23-
timezone=info["timezone"],
24-
compatibility=info["compatibility"],
25-
model=info["model"],
26-
firmware=info["firmware"],
27-
mcu_firmware=info["mcuFirmware"],
28-
wlan_driver=info["wlanDriver"],
23+
timezone=info.get("timezone", None),
24+
compatibility=info.get("compatibility", None),
25+
model=info.get("model",None),
26+
firmware=info.get('firmware', None),
27+
mcu_firmware=info.get("mcuFirmware",None),
28+
wlan_driver=info.get("wlanDriver",None),
2929
room_location=info["roomLocation"]
3030
)
3131
if refresh:

src/blueair_api/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ def transform_data_points(data):
6262
"allpollu": "all_pollution",
6363
}
6464

65-
keys = [key_mapping[key] for key in data["sensors"]]
65+
keys = [key_mapping[key] for key in data.get("sensors", {})]
6666

67-
return [dict(zip(keys, values)) for values in data["datapoints"]]
67+
return [dict(zip(keys, values)) for values in data.get("datapoints", {})]

0 commit comments

Comments
 (0)