Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to disable/enable the added switches/buttons #94

Open
PartemImperium opened this issue Jul 17, 2022 · 0 comments
Open

Add ability to disable/enable the added switches/buttons #94

PartemImperium opened this issue Jul 17, 2022 · 0 comments

Comments

@PartemImperium
Copy link

PartemImperium commented Jul 17, 2022

In addition to adding HomeAssistant discovery to the base MQTT plugin's sensors it also adds some buttons/switches/actions.

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()
It would be nice if like the base MQTT plugin you can disable/enable topics.

EDIT: I didnt know links to code would show the code inline so formatted better knowing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant