]> git.giorgioravera.it Git - homeassistant.git/commitdiff
added shell script to track shelly version
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Tue, 3 Sep 2019 19:52:26 +0000 (21:52 +0200)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Tue, 3 Sep 2019 19:52:26 +0000 (21:52 +0200)
shell_scripts/shelly_upgrade.sh
shell_scripts/shelly_version.sh [new file with mode: 0755]

index 7e879a7efef5afd786ebb04f0f8081de7abef81e..644afa9b19209b02799563d41e9fa6d3726473ce 100755 (executable)
@@ -15,15 +15,15 @@ SHELLY_ID=(
        shelly1-59E18C
        shelly1-24D1A8
        shellybulb-BC8610
-  shellyem-B9E1A0
-  shellyplug-s-7A31CB
+       shellyem-B9E1A0
+       shellyplug-s-7A31CB
 )
 
 echo "Upgrade Shelly Firmware"
 
 for i in "${SHELLY_ID[@]}"
 do
-       echo mosquitto_pub -h $HOST -d -u $USER -P $PASSWORD -t shellies/$i/command -m update_fw
+       mosquitto_pub -h $HOST -d -u $USER -P $PASSWORD -t shellies/$i/command -m update_fw
 done
 
 echo "Done"
diff --git a/shell_scripts/shelly_version.sh b/shell_scripts/shelly_version.sh
new file mode 100755 (executable)
index 0000000..0eaa0b7
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+HASS_HOME="/var/lib/homeassistant/.homeassistant"
+USER=$(awk '/shelly_user/ { print  $2 }' $HASS_HOME/secrets.yaml)
+PASSWORD=$(awk '/shelly_password/ { print  $2 }' $HASS_HOME/secrets.yaml)
+SHELLY_ID=(
+       shelly1.giorgioravera.it
+       shelly2.giorgioravera.it
+       shelly3.giorgioravera.it
+       shelly4.giorgioravera.it
+       shelly5.giorgioravera.it
+       shelly6.giorgioravera.it
+       shelly7.giorgioravera.it
+       shelly8.giorgioravera.it
+       shelly9.giorgioravera.it
+       shellybulb.giorgioravera.it
+       shellyem.giorgioravera.it
+       shellyplugs.giorgioravera.it
+)
+
+echo "Check Shelly Firmware"
+
+for i in "${SHELLY_ID[@]}"
+do
+       ALIVE=$(ping -c 1 $i |grep ttl)
+       if [ ! -z "$ALIVE" ]; then
+               VERSION=$(curl -s --user $USER:$PASSWORD http://$i/status | sed -e "s/},/}\n/g" |grep \"update\" | sed -e "s/,/\n/g" | sed -e "s/:/:\t/g" | awk '/has_update/ { print $2 }')
+               NEW=$(curl -s --user $USER:$PASSWORD http://$i/status | sed -e "s/},/}\n/g" |grep \"update\" | sed -e "s/,/\n/g" | sed -e "s/:/:\t/g" | awk '/new_version/ { print $2 }')
+               OLD=$(curl -s --user $USER:$PASSWORD http://$i/status | sed -e "s/},/}\n/g" |grep \"update\" | sed -e "s/,/\n/g" | sed -e "s/:/:\t/g" | awk '/old_version/ { print $2 }')
+               echo $i: $VERSION - $OLD - $NEW
+       fi
+done
+
+echo "Done"