From 5568000d625c29887d79eefc3ce5c9d7a89a6c89 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 29 Jun 2021 23:49:30 +0200 Subject: [PATCH] initial settings uploader added --- esp32/host/uploadInitialSettings.sh | 74 +++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 esp32/host/uploadInitialSettings.sh diff --git a/esp32/host/uploadInitialSettings.sh b/esp32/host/uploadInitialSettings.sh new file mode 100755 index 0000000..413f32f --- /dev/null +++ b/esp32/host/uploadInitialSettings.sh @@ -0,0 +1,74 @@ +#!//bin/bash + +if [ $# -ne 3 ]; then + echo "Homie prefex and device index must be specified:" + echo "$0 " + echo "e.g." + echo "$0 192.168.0.2 test/ MyDeviceId" + exit 1 +fi + +mqttHost=$1 +mqttPrefix=$2 +homieId=$3 + +mosquitto_pub -h $mqttHost -t "${mqttPrefix}${homieId}/stay/alive/set" -m "1" -r +echo "Waiting ..." +mosquitto_sub -h $mqttHost -t "${mqttPrefix}${homieId}/#" -R -C 1 +set -e +mosquitto_pub -h $mqttHost -t "${mqttPrefix}${homieId}/\$implementation/config/set" -m "{ + \"settings\": { + \"sleep\":600, + \"nightsleep\": 1200, + \"pumpsleep\": 5, + \"tankmax\": 1000, + \"tankmin\": 100, + \"tankwarn\": 200, + \"tankVolume\": 100, + \"lipoDSAddr\": \"abcdefghijklmnop\", + \"tankDSAddr\": \"abcdefghijklmnop\", + \"ntpServer\":\"pool.ntp.org\", + \"dry0\":5000, + \"hourstart0\":6, + \"hourend0\":20, + \"lowLight0\": false, + \"delay0\": 10, + \"dry1\":5000, + \"hourstart1\":6, + \"hourend1\":20, + \"lowLight1\": false, + \"delay1\": 10, + \"dry2\":5000, + \"hourstart2\":6, + \"hourend2\":20, + \"lowLight2\": false, + \"delay2\": 10, + \"dry3\":5000, + \"hourstart3\":6, + \"hourend3\":20, + \"lowLight3\": false, + \"delay3\": 10, + \"dry4\":5000, + \"hourstart4\":6, + \"hourend4\":20, + \"lowLight4\": false, + \"delay4\": 10, + \"dry5\":5000, + \"hourstart5\":6, + \"hourend5\":20, + \"lowLight5\": false, + \"delay5\": 10, + \"dry6\":5000, + \"hourstart6\":6, + \"hourend6\":20, + \"lowLight6\": false, + \"delay6\": 10 + } +}" -r +echo "Waiting for reboot" +sleep 1 +mosquitto_sub -h $mqttHost -t "${mqttPrefix}${homieId}/#" -R -C 1 +mosquitto_pub -h $mqttHost -t "${mqttPrefix}${homieId}/config/backup/set" -m "true" -r + +mosquitto_pub -h $mqttHost -t "${mqttPrefix}${homieId}/stay/alive/set" -m "0" -r +exit 0