#!/bin/bash
-HASS_HOME="/config"
+if [ -f /.dockerenv ]; then
+ HASS_HOME="/config"
+else
+ HASS_HOME="../"
+fi
USER=$(awk '/shelly_user/ { print $2 }' $HASS_HOME/secrets.yaml)
PASSWORD=$(awk '/shelly_password/ { print $2 }' $HASS_HOME/secrets.yaml)
SHELLY_ID=(
do
ALIVE=$(ping -c 1 $i |grep ttl)
if [ ! -z "$ALIVE" ]; then
- STATUS=$(curl -s --user $USER:$PASSWORD http://$i/reboot | sed -e "s/{"ok"}://g")
- echo $STATUS
+ STATUS=$(curl -s --user $USER:$PASSWORD http://$i/reboot | jq -r .ok)
+ echo $i: $STATUS
fi
done
#!/bin/bash
-HASS_HOME="/config"
+if [ -f /.dockerenv ]; then
+ HASS_HOME="/config"
+else
+ HASS_HOME="../"
+fi
HOST=$(awk '/mqtt_host/ { print $2 }' $HASS_HOME/secrets.yaml)
USER=$(awk '/mqtt_user/ { print $2 }' $HASS_HOME/secrets.yaml)
PASSWORD=$(awk '/mqtt_password/ { print $2 }' $HASS_HOME/secrets.yaml)
--- /dev/null
+#!/bin/bash
+
+if [ -f /.dockerenv ]; then
+ HASS_HOME="/config"
+else
+ HASS_HOME="../"
+fi
+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
+ shelly10.giorgioravera.it
+ shelly11.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
+ UPTIME=$(curl -s --user $USER:$PASSWORD http://$i/status | jq -r .uptime)
+ echo $i: $UPTIME
+ fi
+done
+
+echo "Done"
#!/bin/bash
-HASS_HOME="/config"
+if [ -f /.dockerenv ]; then
+ HASS_HOME="/config"
+else
+ HASS_HOME="../"
+fi
USER=$(awk '/shelly_user/ { print $2 }' $HASS_HOME/secrets.yaml)
PASSWORD=$(awk '/shelly_password/ { print $2 }' $HASS_HOME/secrets.yaml)
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
+ HAS_UPDATE=$(curl -s --user $USER:$PASSWORD http://$i/status | jq -r .update.has_update)
+ NEW=$(curl -s --user $USER:$PASSWORD http://$i/status | jq -r .update.new_version)
+ OLD=$(curl -s --user $USER:$PASSWORD http://$i/status | jq -r .update.old_version)
+ if [ $HAS_UPDATE == "true" ]; then
+ echo $i: version: $OLD - new version: $NEW
+ else
+ echo $i: version: $OLD - new version: N/A
+ fi
fi
done