Skip to content

Commit 087bb52

Browse files
committed
Fix sensor enable/disable
1 parent a8dfd0a commit 087bb52

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

octoprint_filamentreload/__init__.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,24 @@ def get_template_configs(self):
4848
return [dict(type="settings", custom_bindings=False)]
4949

5050
def on_event(self, event, payload):
51-
if event == Events.PRINT_STARTED: # If a new print is beginning
52-
self._logger.info("Printing started: Filament sensor enabled")
51+
# Printing
52+
if event in (
53+
Events.PRINT_STARTED,
54+
Events.PRINT_RESUMED
55+
):
56+
self._logger.info("Printing: Filament sensor enabled")
5357
if self.pin != -1:
5458
GPIO.remove_event_detect(self.pin)
5559
GPIO.add_event_detect(self.pin, GPIO.BOTH, callback=self.check_gpio, bouncetime=self.bounce)
56-
elif event in (Events.PRINT_DONE, Events.PRINT_FAILED, Events.PRINT_CANCELLED):
57-
self._logger.info("Printing stopped: Filament sensor disabled")
60+
# Not printing
61+
elif event in (
62+
Events.PRINT_DONE,
63+
Events.PRINT_FAILED,
64+
Events.PRINT_CANCELLED,
65+
Events.PRINT_PAUSED,
66+
Events.ERROR
67+
):
68+
self._logger.info("Not printing: Filament sensor disabled")
5869
try:
5970
GPIO.remove_event_detect(self.pin)
6071
except Exception:

0 commit comments

Comments
 (0)