-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
In addition to adding HomeAssistant discovery to the base MQTT plugin's sensors it also adds some buttons/switches/actions.
OctoPrint-HomeAssistant/octoprint_homeassistant/__init__.py
Lines 659 to 727 in de9529c
| def _on_emergency_stop( | |
| self, topic, message, retained=None, qos=None, *args, **kwargs | |
| ): | |
| self._logger.debug("Emergency stop message received: " + str(message)) | |
| if message: | |
| self._printer.commands("M112") | |
| def _on_cancel_print( | |
| self, topic, message, retained=None, qos=None, *args, **kwargs | |
| ): | |
| self._logger.debug("Cancel print message received: " + str(message)) | |
| if message: | |
| self._printer.cancel_print() | |
| def _on_pause_print(self, topic, message, retained=None, qos=None, *args, **kwargs): | |
| self._logger.debug("Pause print message received: " + str(message)) | |
| if message: | |
| self._printer.pause_print() | |
| else: | |
| self._printer.resume_print() | |
| def _on_shutdown_system(self, topic, message, retained=None, qos=None, *args, **kwargs): | |
| self._logger.debug("Shutdown print message received: " + str(message)) | |
| if message: | |
| shutdown_command = self._settings.global_get( | |
| ["server", "commands", "systemShutdownCommand"] | |
| ) | |
| try: | |
| import sarge | |
| sarge.run(shutdown_command, async_=True) | |
| except Exception as e: | |
| self._logger.info("Unable to run shutdown command: " + str(e)) | |
| def _on_restart_system(self, topic, message, retained=None, qos=None, *args, **kwargs): | |
| self._logger.debug("Reboot print message received: " + str(message)) | |
| if message: | |
| _command = self._settings.global_get( | |
| ["server", "commands", "systemRestartCommand"] | |
| ) | |
| try: | |
| import sarge | |
| sarge.run(_command, async_=True) | |
| except Exception as e: | |
| self._logger.info("Unable to run system reboot command: " + str(e)) | |
| def _on_restart_server(self, topic, message, retained=None, qos=None, *args, **kwargs): | |
| self._logger.debug("Restart print message received: " + str(message)) | |
| if message: | |
| _command = self._settings.global_get( | |
| ["server", "commands", "serverRestartCommand"] | |
| ) | |
| try: | |
| import sarge | |
| sarge.run(_command, async_=True) | |
| except Exception as e: | |
| self._logger.info("Unable to run system reboot command: " + str(e)) | |
| def _on_psu(self, topic, message, retained=None, qos=None, *args, **kwargs): | |
| message = message.decode() | |
| self._logger.debug("PSUControl message received: " + message) | |
| if message == "True": | |
| self._logger.info("Turning on PSU") | |
| self.turn_psu_on() | |
| else: | |
| self._logger.info("Turning off PSU") | |
| self.turn_psu_off() |
EDIT: I didnt know links to code would show the code inline so formatted better knowing that.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels