Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: setting position to an arbitrary value just opens/closes it completely #3

Open
knoopx opened this issue Jul 11, 2021 · 1 comment · May be fixed by #5
Open

bug: setting position to an arbitrary value just opens/closes it completely #3

knoopx opened this issue Jul 11, 2021 · 1 comment · May be fixed by #5

Comments

@knoopx
Copy link

knoopx commented Jul 11, 2021

hi, just found your fork which solves the input delay I was having with the original implementation but it does not seem to properly handle arbitrary position values. is that expected?

@lbossle
Copy link

lbossle commented Feb 18, 2022

Hey, I encounter the same problem. But only sometimes. I think it has something to do with this

def start_auto_updater(self):
"""Start the autoupdater to update HASS while cover is moving."""
_LOGGER.debug(self._name + ': ' + 'start_auto_updater')
if self._unsubscribe_auto_updater is None:
_LOGGER.debug(self._name + ': ' + 'init _unsubscribe_auto_updater')
interval = timedelta(seconds=0.1)
self._unsubscribe_auto_updater = async_track_time_interval(
self.hass, self.auto_updater_hook, interval)
@callback
def auto_updater_hook(self, now):
"""Call for the autoupdater."""
self.async_schedule_update_ha_state()
if self.position_reached():
_LOGGER.debug(self._name + ': ' + 'auto_updater_hook :: position_reached')
self.stop_auto_updater()
self.hass.async_create_task(self.auto_stop_if_necessary())

def position_reached(self):
"""Return if cover has reached designated position."""
return self.current_position() == self.travel_to_position

I think the issue is that when you are unlucky position_reached() is sometimes called too late due to the interval (so the condition is never met) and thus the cover just keeps on going.

Possible solutions:

  1. Decrease increment -> Only less probable occurance
  2. Use >= and <= in the comparison depending on the travel direction of the cover

I will try to fix this using the second option and create a pull request.

@lbossle lbossle linked a pull request Feb 19, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants