Skip to content

Commit

Permalink
Merge pull request #211 from basbruss/inverse_sun_position
Browse files Browse the repository at this point in the history
Apply always inverse state if selected
  • Loading branch information
basbruss authored Jun 12, 2024
2 parents d7a86ac + 9f9d602 commit 575b6f6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions custom_components/adaptive_cover/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ async def async_handle_timed_refresh(self, options):
if self.control_toggle:
for cover in self.entities:
await self.async_set_manual_position(
cover, options.get(CONF_SUNSET_POS)
cover,
inverse_state(options.get(CONF_SUNSET_POS))
if self._inverse_state
else options.get(CONF_SUNSET_POS),
)
else:
_LOGGER.debug("Timed refresh but control toggle is off")
Expand Down Expand Up @@ -558,7 +561,7 @@ def state(self) -> int:
if self._switch_mode:
state = self.climate_state
if self._inverse_state:
state = 100 - state
state = inverse_state(state)
_LOGGER.debug("Calculated position: %s", state)
return state

Expand Down Expand Up @@ -713,3 +716,8 @@ def binary_cover_manual(self):
def manual_controlled(self):
"""Get the list of covers under manual control."""
return [k for k, v in self.manual_control.items() if v]


def inverse_state(state: int) -> int:
"""Inverse state."""
return 100 - state

0 comments on commit 575b6f6

Please sign in to comment.