first commit

This commit is contained in:
Romulus21
2025-05-29 15:41:18 +02:00
commit 9e68a347b4
2 changed files with 33 additions and 0 deletions

31
sendSMSHandler.py Normal file
View File

@@ -0,0 +1,31 @@
import octoprint.plugin
import requests
class SendSMSHandlerPlugin(octoprint.plugin.EventHandlerPlugin, octoprint.plugin.StartupPlugin):
def on_after_startup(self):
self._logger.info("Send SMS !")
def on_event(self, event, payload):
if event == "PrintDone":
self._logger.info("Print job finished, sending GET request...")
file_name = payload.get("name", "Nom inconnu")
print_time = payload.get("time", 0)
self.send_get_request(file_name, print_time)
def send_get_request(self, file_name, print_time):
url = f"https://smsapi.free-mobile.fr/sendmsg?user=58834922&pass=OgGZvJjNf5GCSU&to=0681952587&msg=Impression terminée de {file_name} en {print_time}"
if url:
try:
response = requests.get(url)
self._logger.info(f"GET request sent to {url}, response: {response.status_code}")
except Exception as e:
self._logger.error(f"Failed to send GET request: {e}")
else:
self._logger.error("URL is not configured in plugin settings.")
__plugin_name__ = "Send SMS"
__plugin_version__ = "1.0.0"
__plugin_description__ = "Send SMS when print is done"
__plugin_pythoncompat__ = ">=3.7,<4"
__plugin_implementation__ = SendSMSHandlerPlugin()