Skip to content

Commit

Permalink
Check explicitly for None value in Overkiz integration (home-assistan…
Browse files Browse the repository at this point in the history
  • Loading branch information
tetienne authored and balloob committed Jan 28, 2022
1 parent 0604185 commit 2ff8f10
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion homeassistant/components/overkiz/cover_entities/awning.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def current_cover_position(self) -> int | None:
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ def current_cover_tilt_position(self) -> int | None:
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
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/overkiz/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ def rgb_color(self) -> tuple[int, int, int] | None:
@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

Expand Down

0 comments on commit 2ff8f10

Please sign in to comment.