Skip to content

Commit

Permalink
Feature/make position events configurable (#145)
Browse files Browse the repository at this point in the history
* Single out ZChange events
* Also include PositionUpdates
  • Loading branch information
oxivanisher authored Jan 7, 2024
1 parent 90fb2db commit 33317b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 6 additions & 5 deletions octoprint_mqtt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class MqttPlugin(octoprint.plugin.SettingsPlugin,
Events.TRANSFER_FAILED, Events.TRANSFER_DONE),
printjob = (Events.PRINT_STARTED, Events.PRINT_FAILED, Events.PRINT_DONE,
Events.PRINT_CANCELLED, Events.PRINT_PAUSED, Events.PRINT_RESUMED),
gcode = (Events.POWER_ON, Events.POWER_OFF, Events.HOME, Events.Z_CHANGE,
Events.DWELL, Events.WAITING, Events.COOLING, Events.ALERT,
Events.CONVEYOR, Events.EJECT, Events.E_STOP, Events.POSITION_UPDATE,
Events.TOOL_CHANGE),
gcode = (Events.POWER_ON, Events.POWER_OFF, Events.HOME, Events.DWELL,
Events.WAITING, Events.COOLING, Events.ALERT, Events.CONVEYOR,
Events.EJECT, Events.E_STOP, Events.TOOL_CHANGE),
position = (Events.Z_CHANGE, Events.POSITION_UPDATE),
timelapse= (Events.CAPTURE_START, Events.CAPTURE_FAILED, Events.CAPTURE_DONE,
Events.MOVIE_RENDERING, Events.MOVIE_FAILED, Events.MOVIE_FAILED),
slicing = (Events.SLICING_STARTED, Events.SLICING_DONE, Events.SLICING_CANCELLED,
Expand Down Expand Up @@ -119,6 +119,7 @@ def get_settings_defaults(self):
files=True,
printjob=True,
gcode=True,
position=True,
timelapse=True,
slicing=True,
settings=True,
Expand Down Expand Up @@ -323,7 +324,7 @@ def mqtt_connect(self):
if self._mqtt is None:
self._mqtt = mqtt.Client(client_id=client_id, protocol=protocol, clean_session=clean_session)
else:
self._mqtt.reinitialise() #otherwise tls_set might be called again causing the plugin to crash
self._mqtt.reinitialise() #otherwise tls_set might be called again causing the plugin to crash

if broker_username is not None:
self._mqtt.username_pw_set(broker_username, password=broker_password)
Expand Down
7 changes: 5 additions & 2 deletions octoprint_mqtt/templates/mqtt_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
<span class="help-block">{{ _('Paths to the PEM encoded private keys, <strong>must not be password protected</strong>, only necessary if broker requires client certificate authentication.') }}</span>
</div>
</div>

<div class="control-group">
<label class="control-label">{{ _('Ciphers') }}</label>
<div class="controls">
Expand Down Expand Up @@ -218,6 +218,10 @@
<label class="checkbox"><input type="checkbox" data-bind="checked: settings.publish.events.gcode" /> {{ _('GCode processing events') }} </label>
<span class="help-block">{{ _('Events triggered due to GCODE commands like M80 (Power On), M81 (Power Off), ...') }}</span>
</div>
<div class="controls">
<label class="checkbox"><input type="checkbox" data-bind="checked: settings.publish.events.position" /> {{ _('Position events') }} </label>
<span class="help-block">{{ _('Position events like ZChange and PositionUpdate') }}</span>
</div>
<div class="controls">
<label class="checkbox"><input type="checkbox" data-bind="checked: settings.publish.events.timelapse" /> {{ _('Timelapse events') }} </label>
<span class="help-block">{{ _('Capture start, capture done, ...') }}</span>
Expand Down Expand Up @@ -326,4 +330,3 @@
</form>

<p class="muted"><small>{{ _('If you need help on setting up this plugin, please have a look at <a href="%(url)s" target="_blank">the documentation on Github</a>.', url = "https://github.com/OctoPrint/OctoPrint-MQTT/blob/master/README.md") }}</small></p>

0 comments on commit 33317b8

Please sign in to comment.