Check explicitly for None value in Overkiz integration (#65045)

pull/65442/head
Thibaut 2022-01-28 10:58:42 +01:00 committed by Paulus Schoutsen
parent 0604185854
commit 2ff8f10b9f
3 changed files with 8 additions and 5 deletions

View File

@ -48,7 +48,8 @@ class Awning(OverkizGenericCover):
None is unknown, 0 is closed, 100 is fully open.
"""
if current_position := self.executor.select_state(OverkizState.CORE_DEPLOYMENT):
current_position = self.executor.select_state(OverkizState.CORE_DEPLOYMENT)
if current_position is not None:
return cast(int, current_position)
return None

View File

@ -51,9 +51,10 @@ class OverkizGenericCover(OverkizEntity, CoverEntity):
None is unknown, 0 is closed, 100 is fully open.
"""
if position := self.executor.select_state(
position = self.executor.select_state(
OverkizState.CORE_SLATS_ORIENTATION, OverkizState.CORE_SLATE_ORIENTATION
):
)
if position is not None:
return 100 - cast(int, position)
return None

View File

@ -79,8 +79,9 @@ class OverkizLight(OverkizEntity, LightEntity):
@property
def brightness(self) -> int | None:
"""Return the brightness of this light (0-255)."""
if brightness := self.executor.select_state(OverkizState.CORE_LIGHT_INTENSITY):
return round(cast(int, brightness) * 255 / 100)
value = self.executor.select_state(OverkizState.CORE_LIGHT_INTENSITY)
if value is not None:
return round(cast(int, value) * 255 / 100)
return None