Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| sonoff [30.11.2020 13:58] – [Falshing Tasmota Firmware] Pascal Suter | sonoff [07.09.2021 05:52] (current) – [Making the installation permanent] Pascal Suter | ||
|---|---|---|---|
| Line 47: | Line 47: | ||
| here are the steps using Tasmotizer: | here are the steps using Tasmotizer: | ||
| - | * install tasmotizer: <code | + | * install tasmotizer: <code> |
| pip3 install --upgrade pip wheel | pip3 install --upgrade pip wheel | ||
| pip3 install tasmotizer | pip3 install tasmotizer | ||
| tasmotizer.py</ | tasmotizer.py</ | ||
| * under " | * under " | ||
| - | * connect your sonoff to the serial2usb adapter WITH MAINS DISCONNECTED!! hold down the push button and plug-in the usb adapter. | + | * connect your sonoff to the serial2usb adapter WITH MAINS DISCONNECTED!! |
| + | * here's the pinout for a shelly1 .. with the shelly1 you need to connect the gpio1 pin to ground whil you power it on in order to get it into flash mode.. {{: | ||
| + | * hold down the push button and plug-in the usb adapter. | ||
| * let go of the push button and click " | * let go of the push button and click " | ||
| * click " | * click " | ||
| Line 203: | Line 205: | ||
| copy the '' | copy the '' | ||
| + | |||
| + | It happened a couple of times, that the mqtt-dss-bridge process was running without actually updating the state of the dss target. this happened after some network issues for example. since the mqtt-dss-bridge process did not exit but rather continued to run and just do nothing, systemd did not notice any problem and did not restart the service. for that reason I created a little wrapper script which checks the age of the last status update and exits with exit code 1 if that state is older than 10 seconds for longer than 10 seconds (it usually takes a couple of seconds upon starting the gateway to catch up, hence we wait 10 addiitonal seconds before killing mqtt-dss-bridge and exiting with an error state) | ||
| + | |||
| + | This wrapper also mutes the output of mqtt-dss-bridge which otherwise floods your syslog. | ||
| + | |||
| + | save this script to a convenient location such as ''/ | ||
| + | <code bash / | ||
| + | #!/bin/bash | ||
| + | |||
| + | # start the bridge in the background | ||
| + | / | ||
| + | PID=$! | ||
| + | echo "DSS Bridge started with PID $PID" | ||
| + | # start a loop to monitor the status every second | ||
| + | errcntr=0 | ||
| + | lastUpdate=999 | ||
| + | while true; do | ||
| + | lastUpdate=$(( \ | ||
| + | $(date +%s)\ | ||
| + | -\ | ||
| + | $(date -d "$(\ | ||
| + | mosquitto_sub -h localhost -u sonoffs -P sonoff -t dss/ | ||
| + | sed -E -e ' | ||
| + | )" +%s)\ | ||
| + | )) | ||
| + | if [ 10 -lt $lastUpdate ]; then | ||
| + | if [ $errcntr -lt 10 ]; then | ||
| + | let errcntr++ | ||
| + | echo "DSS Bridge state is too old (last updated $lastUpdate seconds ago, max 10 allowed). This was failure $errcntr out of 10 accepted failures" | ||
| + | else | ||
| + | echo "DSS bridge state is still too old ($lastUpdate seconds) after 10 retries. killing mqtt-dss-bridge (pid $PID) and exit with error status 1" | ||
| + | kill $PID | ||
| + | exit 1 | ||
| + | fi | ||
| + | fi | ||
| + | sleep 1 | ||
| + | done | ||
| + | </ | ||
| create the startup service file for '' | create the startup service file for '' | ||
| Line 209: | Line 249: | ||
| [Unit] | [Unit] | ||
| Description=Node.js MQTT DSS Bridge | Description=Node.js MQTT DSS Bridge | ||
| - | Requires=mosquitto.service | + | # Requires |
| - | After=mosquitto.service | + | Requires=After=mosquitto.service |
| [Service] | [Service] | ||
| - | ExecStart=/usr/bin/node /usr/local/lib/ | + | # |
| + | ExecStart=/usr/local/bin/ | ||
| # Required on some systems | # Required on some systems | ||
| # | # | ||
| Restart=always | Restart=always | ||
| - | # Restart service after 10 seconds if node service crashes | + | # Restart service after 10 seconds if wrapper exits with code > 0 |
| RestartSec=10 | RestartSec=10 | ||
| # Output to syslog | # Output to syslog | ||