diff --git a/config/configuration.yaml b/config/configuration.yaml index bb6852e..c791ca4 100644 --- a/config/configuration.yaml +++ b/config/configuration.yaml @@ -11,6 +11,8 @@ frontend: logger: default: "info" + logs: + custom_components.adaptive_cover: debug cover: - platform: template diff --git a/custom_components/adaptive_cover/coordinator.py b/custom_components/adaptive_cover/coordinator.py index c3f963c..59b6299 100644 --- a/custom_components/adaptive_cover/coordinator.py +++ b/custom_components/adaptive_cover/coordinator.py @@ -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.""" @@ -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() @@ -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), @@ -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,