Fix possible KeyError exception in Airzone Cloud (#93747)

airzone_cloud: fix KeyError for Aidoo installations

Some Airzone Cloud installations might be limited to Aidoo devices. In that
case, the library will provide AZD_AIDOOS, but it won't provide AZD_ZONES,
resulting in a KeyError exception.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
Álvaro Fernández Rojas 2023-05-29 20:22:42 +02:00 committed by GitHub
parent 067fc079a3
commit a3ce1ac497
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,7 +45,7 @@ async def async_setup_entry(
coordinator = hass.data[DOMAIN][entry.entry_id] coordinator = hass.data[DOMAIN][entry.entry_id]
sensors = [] sensors = []
for zone_id, zone_data in coordinator.data[AZD_ZONES].items(): for zone_id, zone_data in coordinator.data.get(AZD_ZONES, {}).items():
for description in ZONE_SENSOR_TYPES: for description in ZONE_SENSOR_TYPES:
if description.key in zone_data: if description.key in zone_data:
sensors.append( sensors.append(