Created
August 8, 2021 22:11
-
-
Save pfichtner/440a5e3c506996d5fc968d0978bc9061 to your computer and use it in GitHub Desktop.
Waits til device is online and then sends the new compiled firmware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # waits til device is online and then sends the new compiled firmware | |
| # uses https://esphome.io/components/deep_sleep.html#deep-sleep-prevent-action but should also work without it | |
| if [ $# -eq 0 ]; then | |
| echo "No arguments supplied" | |
| exit 1 | |
| fi | |
| devicename=$1 | |
| ota_topic="$devicename/ota_mode" | |
| sleep_topic="$devicename/sleep_mode" | |
| mosquitto_pub -h mqtt -t "$ota_topic" -m "ON" -r | |
| # wait for any fresh status message from that device (on very rare conditions this could be the OFFLINE message) | |
| mosquitto_sub -h mqtt -t "$devicename/status" -R -C 1 | |
| # republish ota_mode (now the sensor is awake) in case thr retained offline message was not received already by the sensor | |
| mosquitto_pub -h mqtt -t "$ota_topic" -m "ON" | |
| # upload firmware | |
| docker run --rm --net=host -v "%%%insert_path_to_esphome_config%%%/":/config -it esphome/esphome upload $devicename.yaml | |
| mosquitto_pub -h mqtt -t "$ota_topic" -m "" -r | |
| mosquitto_pub -h mqtt -t "$sleep_topic" -m "ON" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment