-
-
Save TheGroundZero/4ea90aa9788ac91c3193d6fbe03b23c3 to your computer and use it in GitHub Desktop.
# See docs on HTTP API | |
# https://shelly-api-docs.shelly.cloud/#settings | |
# Linux / Mac | |
for i in {2..254}; do curl -m 1 http://192.168.1.$i/settings?<setting parameters>; done | |
# Windows | |
# Note: use %% instead of % when saving this in a BATCH script (.bat) | |
FOR /L %I IN (2,1,254) DO curl -m 1 http://192.168.1.%I/settings?<setting parameters> | |
# --- EXAMPLES --- | |
# -- Installing FW upgrade -- | |
# MQTT | |
# See https://shelly-api-docs.shelly.cloud/#common-mqtt-commands | |
Send `update_fw` to `shellies/command` | |
# HTTP API | |
# See https://shelly-api-docs.shelly.cloud/#ota | |
# Linux / Mac | |
for i in {2..254}; do curl -m 1 http://192.168.1.$i/ota?update=true; done | |
# Windows | |
FOR /L %I IN (2,1,254) DO curl -m 1 http://192.168.1.%I/ota?update=true | |
# -- Enabling CoIoT -- | |
# Linux/Mac | |
for i in {2..254}; do curl -m 1 http://192.168.1.$i/settings?coiot_enable=true&coiot_peer=192.168.x.x; done | |
# Windows in CMD (in a .bat use %% instead of %) | |
FOR /L %I IN (2,1,254) DO curl -m 1 http://192.168.1.%I/settings?coiot_enable=true&coiot_peer=192.168.x.x | |
# -- Disable MQTT update period -- | |
# Linux/Mac | |
for i in {2..254}; do curl -m 1 http://192.168.1.$i/settings?mqtt_update_period=0; done | |
# Windows in CMD (in a .bat use %% instead of %) | |
FOR /L %I IN (2,1,254) DO curl -m 1 http://192.168.1.%I/settings?mqtt_update_period=0 |
@TheGroundZero I saw that page, but nothing seems to be correct. Every time I try to change something using http, I seem to have to replace the . with _ to get it to work. So if that page says "sntp.server", I have to use "sntp_server", "coiot.peer" has to become "coiot_peer" and I've got that with more options.
@TheGroundZero I saw that page, but nothing seems to be correct. Every time I try to change something using http, I seem to have to replace the . with _ to get it to work. So if that page says "sntp.server", I have to use "sntp_server", "coiot.peer" has to become "coiot_peer" and I've got that with more options.
Be wary of the difference between the response attributes and request parameteres.
A request to e.g. http://192.168.x.x/settings
will return a JSON object containing e.g.
{
"device": {
"type": "SHSW-21",
"mac": "16324CAABBCC",
"hostname": "shelly1-B929CC"
},
# ...
"sntp": {
"server": "time.google.com",
"enabled": true
},
# ...
}
So you can extract the key-value pairs device.type
= SHSW-21
and sntp.server
= time.google.com
.
To modify e.g. the SNTP server, you need to look at the HTTP Parameters section and send a GET request to http://192.168.x.x/settings?sntp_server=my_timeserver.domain.tld
@TheGroundZero I know about the JSON-response, that part was obvious and is as easy as using
response = requests.get("http://IP-address/settings", timeout=0.500)
hostname = response.json()["device"]["hostname"]
but having to use _ instead of . for the configuring part (from Python) was not. But now that I know, I can continue with writing a script that will config future Shelly's with a single command :)
Have a look at the Shelly API Reference for more info on what you can change via the API. Note that there's a difference between Gen1 and Gen2 (Plus, Pro, Mini).
coiot_peer might need a port. I seem to recall it auto-filled the default port, but if it doesn't you can add
:5683
as port (thuscoiot_peer=192.168.x.x:5683
)