From: Giorgio Ravera Date: Tue, 3 Sep 2019 19:52:26 +0000 (+0200) Subject: added shell script to track shelly version X-Git-Url: http://git.giorgioravera.it/?a=commitdiff_plain;h=70d6bfe218aadc355ed7bb12a5e19562de07abb9;p=homeassistant.git added shell script to track shelly version --- diff --git a/shell_scripts/shelly_upgrade.sh b/shell_scripts/shelly_upgrade.sh index 7e879a7e..644afa9b 100755 --- a/shell_scripts/shelly_upgrade.sh +++ b/shell_scripts/shelly_upgrade.sh @@ -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 index 00000000..0eaa0b7c --- /dev/null +++ b/shell_scripts/shelly_version.sh @@ -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"