{"id":111,"date":"2020-05-26T18:15:13","date_gmt":"2020-05-26T17:15:13","guid":{"rendered":"https:\/\/www.bolukan.nl\/?p=111"},"modified":"2023-11-01T10:02:49","modified_gmt":"2023-11-01T09:02:49","slug":"install-python-script-on-synology","status":"publish","type":"post","link":"https:\/\/www.bolukan.nl\/?p=111","title":{"rendered":"Install python script on Synology"},"content":{"rendered":"\n<p>After the installation of DSM 6.2.3-25426 on my Synology, the script to listen and log mqtt messages to a database was no longer running. Time to fix the problem!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"186\" height=\"142\" src=\"https:\/\/www.bolukan.nl\/wp-content\/uploads\/2020\/05\/pythonscript.png\" alt=\"Synology and Python\" class=\"wp-image-123\"\/><\/figure>\n\n\n\n<p>As MQTT server I installed Mosquitto via the Synology Add-on manager. Currently the latest version distributed by the SynoCommunity is 1.4.14-9 (http:\/\/packages.synocommunity.com\/). <\/p>\n\n\n\n<p>The python script to listen and log mqtt messages needs the Paho MQTT client and a mysql-connector. Install these packages with PIP, the package installer for <em>Python<\/em>.<\/p>\n\n\n\n<p>SSH to synology server as admin, p.e. using putty<\/p>\n\n\n\n<p>Check the python version:<br><code>&gt;<strong>python3 -V<\/strong><\/code><br><code>Python 3.5.1<\/code><\/p>\n\n\n\n<p>Install PIP:<br><code>&gt;<strong>mkdir \/volume1\/homes\/admin\/pip<\/strong><br>&gt;<strong>cd \/volume1\/homes\/admin\/pip<\/strong><br>&gt;<strong>wget https:\/\/bootstrap.pypa.io\/get-pip.py<\/strong><br>&gt;<strong>sudo python3 get-pip.py<\/strong><br>The scripts pip, pip3 and pip3.5 are installed in '\/volume1\/@appstore\/py3k\/usr\/local\/bin' which is not on PATH.<br>Successfully installed pip-20.1.1<br>&gt;<strong>rm \/volume1\/homes\/admin\/pip -r<\/strong><\/code><\/p>\n\n\n\n<p>Install paho:<br><code>&gt;<strong>sudo \/volume1\/@appstore\/py3k\/usr\/local\/bin\/pip3 install paho-mqtt<\/strong><br>Successfully installed paho-mqtt-1.5.0<\/code><\/p>\n\n\n\n<p>Install mysql-connector:<br><code>&gt;<strong>sudo \/volume1\/@appstore\/py3k\/usr\/local\/bin\/pip3 install mysql-connector-python<\/strong><br>Successfully installed mysql-connector-python-8.0.20 protobuf-3.11.3 six-1.15.0<\/code><\/p>\n\n\n\n<p>You can schedule the python script as Task:<br>General, Task: <strong><code>Python MQTT Logger<\/code><\/strong><br>General, User: <strong><code>root<\/code><\/strong><br>Task Settings, Send run details my email: <strong><code>&lt;you@domain&gt;<\/code><\/strong><br>Task Settings, User-defined script:<br><code><strong>\/volume1\/@appstore\/py3k\/usr\/local\/bin\/python3 \/volume1\/homes\/admin\/mqtt_logger.py<\/strong><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>After the installation of DSM 6.2.3-25426 on my Synology, the script to listen and log mqtt messages to a database was no longer running. Time to fix the problem! As MQTT server I installed Mosquitto via the Synology Add-on manager. Currently the latest version distributed by the SynoCommunity is 1.4.14-9 (http:\/\/packages.synocommunity.com\/). The python script to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[15,13,14],"class_list":["post-111","post","type-post","status-publish","format-standard","hentry","category-software","tag-mqtt","tag-python","tag-synology"],"_links":{"self":[{"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=\/wp\/v2\/posts\/111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=111"}],"version-history":[{"count":6,"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=\/wp\/v2\/posts\/111\/revisions"}],"predecessor-version":[{"id":376,"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=\/wp\/v2\/posts\/111\/revisions\/376"}],"wp:attachment":[{"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bolukan.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}