Skip to content

Commit

Permalink
Improved is_timelapse_pause check
Browse files Browse the repository at this point in the history
  • Loading branch information
Clon1998 committed Jan 2, 2024
1 parent 6c311f2 commit 0881722
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions mobileraker/data/dtos/moonraker/printer_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,8 @@ def current_layer(self) -> int:
@property
def progress(self) -> Optional[int]:
return int(self.print_progress_by_fileposition_relative * 100) if self.print_progress_by_fileposition_relative else None

@property
def is_timelapse_pause(self) -> bool:
return self.print_state == "paused" and self.timelapse_pause is True

6 changes: 3 additions & 3 deletions mobileraker/mobileraker_companion.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def _fulfills_evaluation_threshold(self, snapshot: PrinterSnapshot) -> bool:
self._logger.info('No last snapshot available. Evaluating!')
return True

if self._last_snapshot.print_state != snapshot.print_state and not snapshot.timelapse_pause and not self._last_snapshot.timelapse_pause:
if self._last_snapshot.print_state != snapshot.print_state and not snapshot.is_timelapse_pause and not self._last_snapshot.is_timelapse_pause:
self._logger.info('State changed. Evaluating!')
return True

Expand Down Expand Up @@ -280,7 +280,7 @@ def _state_notification(self, cfg: DeviceNotificationEntry, cur_snap: PrinterSna
return None

# Ignore paused state caused by timelapse plugin
if cur_snap.timelapse_pause:
if cur_snap.is_timelapse_pause:
return None

# collect title and body to translate it
Expand Down Expand Up @@ -467,7 +467,7 @@ async def _update_app_snapshot(self, cfg: DeviceNotificationEntry, printer_snap:
progress_live_activity_update = printer_snap.progress

updated = last.copy_with(
state=printer_snap.print_state if last.state != printer_snap.print_state and not printer_snap.timelapse_pause else None,
state=printer_snap.print_state if last.state != printer_snap.print_state and not printer_snap.is_timelapse_pause else None,
progress=progress_update,
progress_live_activity=progress_live_activity_update,
m117=printer_snap.m117_hash if last.m117 != printer_snap.m117_hash else None,
Expand Down

0 comments on commit 0881722

Please sign in to comment.