Setup Ecosystems
How to install a script on a Shelly
Install a script on a Shelly from the Shelly app or a browser, step by step: create it, paste the code, run it, and keep it running after a restart.
Every script in our Shelly scripts library installs the same way. You can do it from your phone in the Shelly app, or in a browser on the device's own web page. Either takes a couple of minutes.
Before you start
- A Shelly from the Plus, Pro, Gen3 or Gen4 range, already set up. If it isn't yet, add it to the Shelly app first.
- The script, with your values filled in. On a script's page, type them into Make it yours and the code updates to match, then tap or click Copy script.
- For the browser route: a computer, tablet or phone on the same Wi-Fi as the Shelly, and the device's IP address. In the Shelly app, open the device, then Device settings, then Device information.
Install the script
Shelly Smart Control
The Shelly Smart Control app works from anywhere, so you don't need to be home. Pasting a long script is easiest if you copied it on the same phone.
- Open the device and tap Scripts
In Shelly Smart Control, open the room, then the device. Tap Scripts, the { } icon in the menu down the left.
- Tap Create new script
If the device has no scripts yet, the screen says No scripts created. Open library has Shelly's own examples, which you don't need for ours.
- Name it, paste the code, then tap Save
Type a name, such as the script's file name. Tap in the code area, paste the script, then tap Save (the disk icon at the top right).
- Tap the play button
The play button lights up once the script is saved. Tap it and a message says the script has been started.
- Close the editor and turn on Run on startup
Close the editor to get back to the Scripts screen. Turn on Run on startup next to your script, so it starts again after a power cut or a firmware update.
- Check it's on
Run on startup shows on, and a message says the script has been toggled. The script runs on the Shelly, so you can close the app.
Direct access via IP
The device's own web page works without the internet or a Shelly account, and it's the only place with the console, which shows what the script is doing.
- Open the device's web page and click Scripts
Type the device's IP address into your browser's address bar. The device's own page opens. Click Scripts in the menu on the left.
- Click Create script
If the device has no scripts yet, the list says so. Library opens Shelly's own examples, which you don't need for ours.
- Name it, paste the code, then click Save
Type a name, such as the script's file name. Click in the code area, paste the script, then click Save (the disk icon above the code).
- Click Run
Run appears once the script is saved. It starts the script straight away.
- Check the console
The console under the code prints what the script is doing. Each script page tells you the line to look for, such as Internet watchdog started.
- Turn on Run on startup
Click Scripts again. In the list, turn on Run on startup next to your script, so it starts again after a power cut or a firmware update.
- Check it's running
The list shows Running! under the script's name, with Run on startup on. You can close the browser: the script runs on the Shelly.
Change a value later
Open the script, stop it (Stop in the browser, the pause button in the app), change the value in the block at the top of the code (the one that starts with let CONFIG), save, then run it again. Or fill in the new value on the script's page, copy the whole script again and paste it over the old code.
If it doesn't work
- There's no Scripts in the menu. The device is from the Gen1 range, which can't run scripts.
- The web page won't open. Check you're on the same Wi-Fi as the Shelly, not a guest network, and that the address is current. Some routers hand out a new one after a restart: reserving the address in your router stops that.
- It says there's an error, or the console shows one with a line number. Part of the script is usually missing. Copy it again with Copy script and paste it over the whole code area, not just a section.
- It stopped after a power cut. Run on startup is off. Turn it on in the Scripts list.
- The script is turned off after the device restarts. A Shelly turns off a script that made it crash. Paste a fresh copy, and if it happens again, get in touch and tell us which script and device.
Find a script to install
Frequently asked questions
What language are Shelly scripts written in?
JavaScript, in a cut-down form that runs on the device itself. You don't need to write any to use a script from our library: change the values at the top and paste it in.
Do Shelly scripts need the internet?
No. A script runs on the Shelly, so it keeps working without the internet or the Shelly cloud. Only a script that fetches something from outside, such as a weather forecast or a phone notification, needs a connection for that part.
Does a script keep running after a power cut?
Only if Run on startup is on. Without it, the script stays stopped when the device restarts, after a blackout or a firmware update.
Which Shelly devices can run scripts?
Gen2 and newer: the Plus and Pro ranges, Gen3 and Gen4. The original Gen1 devices have no scripting.
Can I install a script from the Shelly app?
Yes. Open the device in Shelly Smart Control, tap Scripts, then Create new script. Paste the code, save it, tap the play button and turn on Run on startup.
Still need a hand?
We answer most messages within one business day. If your question is about an existing order, have your order number ready. It speeds things up.
Contact us