diff --git a/Python-HTTP-OTA-Server.md b/Python-HTTP-OTA-Server.md index 52402ed1..529b11d9 100644 --- a/Python-HTTP-OTA-Server.md +++ b/Python-HTTP-OTA-Server.md @@ -12,7 +12,7 @@ to superuser privileges and installing additional packages (and libraries) on hi Python makes available Flask (micro)framework (http://flask.pocoo.org) that can be used at different levels of complexity due to its modular architecture. A simple HTTP server (hello-world) can be developed only by *six* lines of Python code (http://flask.pocoo.org/docs/1.0/quickstart/#a-minimal-application). -A Flask application to offer Sonoff-Tasmota firmware images for OTA upgrades is available in 'tools' directory (https://github.com/arendst/Sonoff-Tasmota/blob/development/tools/fw-server.py). +A Flask application to offer Sonoff-Tasmota firmware images for OTA upgrades is available in 'tools' directory (https://github.com/arendst/Sonoff-Tasmota/tree/development/tools/fw_server/fw-server.py). ## Requirements @@ -62,4 +62,57 @@ python fw-server.py -i 192.168.1.1 On Windows operating system it is advisable to use '-i' option because Windows uses UUID name for network interfaces that are not so easy to type... +## Linux server: + +If your MQTT broker is hosted on a local server, you may want Tasmota OTA to work the same, as a service. Here is how to achieve this: + +- Copy the python script on the linux server +``` +$ sudo su +# mkdir /srv/tasmota/fw_server/fw +# cd /srv/tasmota/fw_server +# wget https://github.com/arendst/Sonoff-Tasmota/tree/development/tools/fw_server/fw-server.py +``` +- Create a new file '/etc/systemd/system/tasmota.service' and copy those lines : +``` +[Unit] +Description=Local OTA server for Tasmota +Requires=network.target +After=network.target multi-user.target + +[Service] +#User=XYZ +Type=idle +ExecStart=/usr/bin/python /srv/tasmota/fw_server/fw-server.py -d wlan0 +Restart=on-failure + +[Install] +WantedBy=multi-user.target +``` +- User rights + +We have created those files and directories as root but it is not desirable, the option `User=XYZ` should be uncommented and `XYZ` replaced by you usernane. + +In the following command too, replace twice `XYZ` by your username : +``` +# chown -hR XYZ:XYZ /srv/tasmota +``` +- Run the service +``` +# systemctl daemon-reload +# systemctl enable tasmota.service +# systemctl start tasmota.service +``` +- Check the service is active and runnning. +``` +# systemctl status tasmota.service +``` +- Test of the server + +To feed the server, we're now able to copy new firmwares in the folder `/srv/tasmota/fw_server/fw` with `XYZ` user rights. It can be done with `scp` or `samba` for instance. +Let's upload `firmware.bin` into the folder, the service can be tested from any browser by issuing the address `http://:5000/firmware.bin` were is the adress of the linux server. +If you reboot the server, the service should startup again. + +Now if you want PlatformIO to be able to upload your compiled binaries to the local server, you'll still have to setup `ssh` with `ssh-keygen` in order to use the Tasmota script `pio/sftp-uploader.py` without password. +