[Tutorial] Control shellys remote in other networks (Shelly Cloud API)

Since the question of how to control Shellys in a different location has come up several times, I’ll put the whole thing into a small guide. These instructions describe how to control a device outside your network. Of course, the Shelly must be connected to the internet and the Shellycloud at the other location.

First of all, you need the Shelly API Key, which is the only way to access your devices. To do this, log into your account either in the ShellyAPP or via my.shelly.cloud.

Via Settings → User settings → Cloud activation key you can collect your unique key and the corresponding server.
image
You should not give the key to anyone, as it can be used to manage all your Shellys. If you ever change your password in the ShellyCloud, the key will also change!

Next, you need the ID of the device you want to control. To do this, navigate to it and find the Device ID under Settings → Device information.


You also note/copy these down.

With these three pieces of information (API Key, Shelly Server and Device ID) you can remotely control a Shelly.

For this we need the “Then” condition with the logic card
image

Now it is a matter of filling this map with life. (In this example I open a window with a Shelly 2.5 in “Roller Mode”)

Methode: Post
URL: https://shelly-XX-eu.shelly.cloud/device/relay/roller/control(Exchange XX with your shelly server)
Headers: content-type:application/x-www-form-urlencoded (with this we tell the server that we are now transmitting requests in the specified format)
Body: id=XXXXXXXX&direction=open&auth_key=XXXXXXXXXXXXXXXXXXXXXXXXXXX… The ID is your DeviceID and the auth_Key is the API key.

If this tile is now executed, the window, blind or shutter should open. To close, simply send “Close” and to stop “Stop” or you can also send a percentage instead of direction with pospos=[0…100]”.

If you use the Shelly to switch different lights, the API URL changes to

URL: https://shelly-xx-eu.shelly.cloud/device/relay/control
Body: channel=&turn=on&auth_key=XXXXXXXXXXXXXXXXXX…

With the channel ID you tell the Shelly which channel it should switch (0 or 1). With turn you tell the Shelly whether it should switch the relay on or off. Once these basic principles are understood, it is easy to control the other Shellys in the family.

Here you will find a small overview of the individual Shellys and the possibilities to control them:

^^translated with deepl^^

3 Likes