Skip to content

Commit

Permalink
fix: set event loop for client
Browse files Browse the repository at this point in the history
  • Loading branch information
muhlba91 committed Dec 12, 2023
1 parent e0f8943 commit b20c729
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
5 changes: 3 additions & 2 deletions custom_components/hella_onyx/sensors/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ def _start_update_device(self, animation: AnimationValue):
self.hass,
self._end_update_device,
utcnow() + timedelta(seconds=delta + INCREASED_INTERVAL_DELTA),
)
),
self.hass.loop,
)
else:
_LOGGER.debug("end update device %s due to too old data", self._uuid)
Expand Down Expand Up @@ -212,7 +213,7 @@ def _end_update_device(self, *args: Any):
self.hass.loop,
)
elif current_time > start_time:
delta = current_time - (animation.start + keyframe.delay)
delta = current_time - start_time
delta_per_unit = (
self._device.target_brightness.value - animation.current_value
) / keyframe.duration
Expand Down
15 changes: 6 additions & 9 deletions custom_components/hella_onyx/sensors/shutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ def _start_moving_device(self, animation: AnimationValue):
self.hass,
self._end_moving_device,
utcnow() + timedelta(seconds=delta + INCREASED_INTERVAL_DELTA),
)
),
self.hass.loop,
)
else:
_LOGGER.debug("end moving device %s due to too old data", self._uuid)
Expand Down Expand Up @@ -311,10 +312,8 @@ def _end_moving_device(self, *args: Any):
elif (
position_start_time is not None and current_time > position_start_time
) or (angle_start_time is not None and current_time > angle_start_time):
if position_animation is not None:
delta = current_time - (
position_animation.start + position_keyframe.delay
)
if position_animation is not None and position_keyframe.duration > 0:
delta = current_time - position_start_time
delta_per_unit = (
self._device.target_position.value
- position_animation.current_value
Expand All @@ -328,10 +327,8 @@ def _end_moving_device(self, *args: Any):
update,
)
self._device.actual_position.value = update
if angle_animation is not None:
delta = current_time - (
angle_animation.start + angle_keyframe.delay
)
if angle_animation is not None and angle_keyframe.duration > 0:
delta = current_time - angle_start_time
delta_per_unit = (
self._device.target_angle.value - angle_animation.current_value
) / angle_keyframe.duration
Expand Down

0 comments on commit b20c729

Please sign in to comment.