Skip to main content

Introduction to Scripting

Scripting enables programmable logic within automation workflows. It extends standard scene capabilities by supporting dynamic behaviors, runtime condition evaluation, device state management and multi-device orchestration.

This documentation covers script architecture, device interaction and implementation practices for advanced automation scenarios.

The scripting transforms the scenes from static configurations into flexible, programmable automation units that can adapt to a wide range of scenarios.

info

All Script are written in JavaScript, allowing you to use familiar syntax and logic structures to build powerful automations.

Example

The following script demonstrates the basic structure of a Script. It controls a Shelly smart device.

First, it gets a device using its ID and stores it in the variable light. Then it sets a trigger so that an action happens only once when the light turns on. After that, it sends a standard phone notification saying “Hello World! The light has been turned on.”

hello-world.js
var light = Shelly.getDevice("x"); // Replace "x" with your Device ID

Shelly.setTriggerOnce(light, "on", () => {
Shelly.sendPhoneStandardNotification("Hello World! The light has been turned on.");
});