Skip to content

Commit

Permalink
Allow min notification interval to be configured, bump to 1.2.3 (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
crysxd authored Jun 4, 2023
1 parent 5e8f174 commit ab84d56
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions octoprint_octoapp/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def on_print_progress(self, storage, path, progress):
modulus = config["updatePercentModulus"]
highPrecisionStart = config["highPrecisionRangeStart"]
highPrecisionEnd = config["highPrecisionRangeEnd"]
minIntervalSecs = config["minIntervalSecs"]
time_since_last = time.time() - self.last_progress_update
if progress < 100 and progress > 0 and (
(progress % modulus) == 0
Expand All @@ -117,7 +118,7 @@ def on_print_progress(self, storage, path, progress):
self._logger.debug("NOTIFICATION | Updating progress in main interval %s" % self.last_event)
self.send_notification(event=self.EVENT_PRINTING)
self.last_progress_update = time.time()
elif time_since_last > 300:
elif time_since_last > minIntervalSecs:
self._logger.debug("NOTIFICATION | Over %s sec passed since last progress update, sending low priority update" % int(time_since_last))
self.send_notification(event=self.EVENT_PRINTING, only_activities=True)
self.last_progress_update = time.time()
Expand Down Expand Up @@ -283,7 +284,7 @@ def send_notification_blocking_raw(self, targets, high_priority, apnsData, andro
if r.status_code != requests.codes.ok:
raise Exception("Unexpected response code %d" % r.status_code)
else:
self._logger.info("NOTIFICATION | Send was success")
self._logger.info("NOTIFICATION | Send was success %s" % r.json())

# Delete invalid tokens
apps = self.get_apps()
Expand Down
3 changes: 2 additions & 1 deletion octoprint_octoapp/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self):
updatePercentModulus=5,
highPrecisionRangeStart=5,
highPrecisionRangeEnd=5,
minIntervalSecs=300,
sendNotificationUrl="https://europe-west1-octoapp-4e438.cloudfunctions.net/sendNotificationV2",
)

Expand All @@ -41,7 +42,7 @@ def __init__(self):
self.last_send_plugin_state = {}

# !!! Also update in setup.py !!!!
self.plugin_version = "1.2.2"
self.plugin_version = "1.2.3"

notification_plugin = OctoAppNotificationsSubPlugin(self)
self.sub_plugins = [
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
# !!!! Also update in plugin.py !!!!
plugin_version = "1.2.2"
plugin_version = "1.2.3"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit ab84d56

Please sign in to comment.