Created
December 10, 2024 08:11
-
-
Save jk/54449dccb50fb89492aa649b9d48b894 to your computer and use it in GitHub Desktop.
Update MQTT server on multiple shelly relays at once
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/bash | |
# Liste der Shelly-IP-Adressen | |
shelly_ips=("172.19.2.6" "172.19.1.3" "172.19.1.5" "172.19.0.5" "172.19.3.3" "172.19.0.15" "172.19.0.13" "172.19.0.14") | |
# Neue MQTT-Konfiguration | |
mqtt_server="mqtt.example.tld:1883" | |
for ip in "${shelly_ips[@]}"; do | |
server=$(curl -s -X POST -d '{"id":1, "method":"Mqtt.GetConfig"}' http://$ip/rpc | jq .result.server) | |
echo "$ip nutzt aktuell $server" | |
curl -s -X POST -d '{"id":2, "method":"Mqtt.SetConfig", "params":{"config":{"server":"'"$mqtt_server"'"}}}' http://$ip/rpc | |
curl -s -X POST -d '{"id":3, "method":"Shelly.Reboot"}' http://$ip/rpc | |
echo "Shelly bei IP $ip neu gestartet. → http://$ip/#/settings/mqtt" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment