Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
basbruss committed Apr 12, 2024
1 parent b027cce commit 86ae9b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ frontend:

logger:
default: "info"
logs:
custom_components.adaptive_cover: debug

cover:
- platform: template
Expand Down
13 changes: 10 additions & 3 deletions custom_components/adaptive_cover/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def __init__(self, hass: HomeAssistant) -> None: # noqa: D107
self.state_change = False
self.state_change_data: StateChangedData | None = None
self.manager = AdaptiveCoverManager(self.manual_duration)
self.send_call = False

async def async_config_entry_first_refresh(self):
"""Call the first update from config_entry."""
Expand Down Expand Up @@ -171,9 +172,13 @@ async def _async_update_data(self) -> AdaptiveCoverData:

self.default_state = round(NormalCoverState(cover_data).get_state())

state_range = range(
int(self.state - self.min_change), int(self.state + 1 + self.min_change)
)

if self.state_change:
self.manager.state_change(
self.state_change_data, self.state, self._cover_type, self.manual_reset
self.state_change_data, state_range, self._cover_type, self.manual_reset
)
self.state_change = False # reset state change
await self.manager.reset_if_needed()
Expand Down Expand Up @@ -296,7 +301,9 @@ def common_data(self):
return [
self.config_entry.options.get(CONF_SUNSET_POS),
self.config_entry.options.get(CONF_SUNSET_OFFSET),
self.config_entry.options.get(CONF_SUNRISE_OFFSET,self.config_entry.options.get(CONF_SUNSET_OFFSET)),
self.config_entry.options.get(
CONF_SUNRISE_OFFSET, self.config_entry.options.get(CONF_SUNSET_OFFSET)
),
self.hass.config.time_zone,
self.config_entry.options.get(CONF_FOV_LEFT),
self.config_entry.options.get(CONF_FOV_RIGHT),
Expand Down Expand Up @@ -399,7 +406,7 @@ def state_change(self, states_data, our_state, blind_type, allow_reset):
else:
new_position = new_state.attributes.get("current_position")

if new_position != our_state:
if new_position not in our_state:
_LOGGER.debug(
"Set manual control for %s, for at least %s seconds, reset_allowed: %s",
entity_id,
Expand Down

0 comments on commit 86ae9b9

Please sign in to comment.