Skip to content

Commit

Permalink
Cover: fix position update (#537)
Browse files Browse the repository at this point in the history
* always callback cover position update

when a cover can't move (eg. locked) and `set_down()` is called the travelcalculator starts. because of _position_current.value has not changed in this case its callback is not called when a GroupValueResponse comes in - eg. `sync()` is used.

* only callback if there has been a change in position
  • Loading branch information
farmio committed Dec 21, 2020
1 parent 551f18b commit 03c9673
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions xknx/devices/cover.py
Expand Up @@ -253,11 +253,13 @@ async def _target_position_from_rv(self):

async def _current_position_from_rv(self):
"""Update the current postion from RemoteValue (Callback)."""
position_before_update = self.travelcalculator.current_position()
if self.is_traveling():
self.travelcalculator.update_position(self.position_current.value)
else:
self.travelcalculator.set_position(self.position_current.value)
await self.after_update()
if position_before_update != self.travelcalculator.current_position():
await self.after_update()

async def set_angle(self, angle):
"""Move cover to designated angle."""
Expand Down Expand Up @@ -325,7 +327,7 @@ async def process_group_write(self, telegram):
self.travelcalculator.stop()
await self.after_update()

await self.position_current.process(telegram)
await self.position_current.process(telegram, always_callback=True)
await self.position_target.process(telegram)
await self.angle.process(telegram)

Expand Down

0 comments on commit 03c9673

Please sign in to comment.