Check explicitly for None value in Overkiz integration (#65045)
parent
0604185854
commit
2ff8f10b9f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue