Fix situation where 'model' can be None (string) in Overkiz (#64320)

This commit is contained in:
Mick Vleeshouwer 2022-01-18 19:04:26 -08:00 committed by GitHub
parent 3c7005d4dc
commit 394c6850a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
from enum import unique from enum import unique
from typing import cast
from pyoverkiz.enums import OverkizAttribute, OverkizState from pyoverkiz.enums import OverkizAttribute, OverkizState
from pyoverkiz.models import Device from pyoverkiz.models import Device
@ -59,23 +60,22 @@ class OverkizEntity(CoordinatorEntity):
) )
model = ( model = (
str( self.executor.select_state(
self.executor.select_state( OverkizState.CORE_MODEL,
OverkizState.CORE_MODEL, OverkizState.CORE_PRODUCT_MODEL_NAME,
OverkizState.CORE_PRODUCT_MODEL_NAME, OverkizState.IO_MODEL,
OverkizState.IO_MODEL,
),
) )
or self.device.widget or self.device.widget.value
) )
return DeviceInfo( return DeviceInfo(
identifiers={(DOMAIN, self.executor.base_device_url)}, identifiers={(DOMAIN, self.executor.base_device_url)},
name=self.device.label, name=self.device.label,
manufacturer=str(manufacturer), manufacturer=str(manufacturer),
model=model, model=str(model),
sw_version=str( sw_version=cast(
self.executor.select_attribute(OverkizAttribute.CORE_FIRMWARE_REVISION) str,
self.executor.select_attribute(OverkizAttribute.CORE_FIRMWARE_REVISION),
), ),
hw_version=self.device.controllable_name, hw_version=self.device.controllable_name,
suggested_area=self.coordinator.areas[self.device.place_oid], suggested_area=self.coordinator.areas[self.device.place_oid],