Shelly to Shelly Standalone without Wi-fi (but with Wi-fi)
- Home
- Application guide
- Shelly to Shelly Standalone without Wi-fi (but with Wi-fi)
Introduction:
Even though you are in an area with missing Wi-Fi coverage, it’s actually possible to make two or more Shelly devices integrate with each other based on Actions (Webhooks) and the range extender function.
In this example, we will use two Shelly Plus 1PM units.
The one with the Range Extender enabled we call the Master.
The other one we call the Slave
Note:
Since we are using the device’s without a internet connection, it’s not possible to use the Schedule function.
*Update* Script Version
If you just want a simple follow function where one or more relays (up to four) automatically mirror the state of a master relay.
this can now be done easily with a script.
If you rae new to this you still have to follow step 1-3(4)
Note:
This script only mirrors the ON/OFF status from one relay to others.
If you need two-way synchronization (where both relays follow each other),
you still need to follow the original guide below.
Access Point Switch Sync script:
- Detects all devices connected to the Shelly’s access point.
- Sends the current switch state (on/off) to each connected client.
- Automatically keeps all connected devices synchronized.
- Supports up to 4 clients per access point
Tested with FW 1.7.1
Setup steps
- Enable Range extender mode on your Shelly device
(Settings → Wi-Fi → Access Point → Enable) - Upload the script under
(Settings → Scripts → Add new script → Paste code → Save & Enable)
Note: make sure to toggle “Run on startup” - Connect other Shellys to this AP (they will act as clients).
See how to add Script guide here.
Notes
- Works for Switch components only (not Light).
- Max 4 connected devices recommended.
- Works only with channel ID:0 (can be adjustet in script settings)
Script der skal på "Master"
/*
Automatically detects all devices connected to the access point
and synchronizes the switch state with them.
!!Script can handle max 4 connected devices!!
*/
try {
// CONFIG
let SWITCH_ID = 0; // which relay we follow
let TARGET_ENDPOINT = "/rpc/Switch.Set?id=0&on="; // webhook path
function sendToClients(state) {
print("Fetching AP clients...");
Shelly.call("Wifi.ListAPClients", {}, function(result, err) {
if (err) {
print("Error getting AP clients:", JSON.stringify(err));
return;
}
let clients = result.ap_clients;
if (!clients || clients.length === 0) {
print("No clients connected to AP");
return;
}
print("Found", clients.length, "clients");
for (let i = 0; i < clients.length; i++) {
let ip = clients[i].ip;
if (!ip) continue;
let url = "http://" + ip + TARGET_ENDPOINT + (state ? "true" : "false");
print("-> Sending command to", ip, ":", url);
Shelly.call("HTTP.GET", { url: url }, function(res, err) {
if (err) {
print("Error sending to", ip, ":", JSON.stringify(err));
} else {
print("Response from", ip, ":", JSON.stringify(res));
}
});
}
});
}
// Event listener
Shelly.addEventHandler(function(event) {
if (event.component === "switch:" + SWITCH_ID &&
event.info && event.info.event === "toggle") {
let newState = event.info.state; // true = on, false = off
print("Switch", SWITCH_ID, "toggled. New state:", newState);
sendToClients(newState);
}
});
print("Follow script started. Waiting for toggle events...");
} catch (e) {
print("Error in follow script:", e.message || e);
} Hvis man også vil have mulighed for at styre lys fra “Slaver”
Skal dette script lægges på de enheder der er slaver
Script der skal på "Slaver"
/*************************************************
* Relay mirror sender
*
* Watches local relay state and sends it to
* another Shelly device via HTTP GET RPC call.
*************************************************/
let CONFIG = {
local_switch_id: 0, // Relæ på denne enhed
target_ip: "192.168.33.1",
target_switch_id: 0, // Relæ på modtager-enheden
debug: true
};
let lastSentState = null;
// ---------- Helpers ----------
function log() {
if (!CONFIG.debug) return;
print.apply(null, arguments);
}
function buildUrl(state) {
return "http://" + CONFIG.target_ip +
"/rpc/Switch.Set?id=" + CONFIG.target_switch_id +
"&on=" + (state ? "true" : "false");
}
function sendRelayState(state) {
let url = buildUrl(state);
log("[SEND] Relay state:", state ? "ON" : "OFF");
log("[URL] ", url);
Shelly.call("HTTP.GET", { url: url }, function (res, err_code, err_msg) {
if (err_code !== 0) {
print("[ERROR] HTTP.GET failed:", err_code, err_msg);
return;
}
log("[OK] State sent successfully");
});
}
function handleState(state) {
if (lastSentState === state) {
log("[SKIP] Same state as last sent:", state ? "ON" : "OFF");
return;
}
lastSentState = state;
sendRelayState(state);
}
function readAndSendCurrentState() {
Shelly.call("Switch.GetStatus", { id: CONFIG.local_switch_id }, function (res, err_code, err_msg) {
if (err_code !== 0) {
print("[ERROR] Switch.GetStatus failed:", err_code, err_msg);
return;
}
if (typeof res.output === "boolean") {
log("[INIT] Current relay state:", res.output ? "ON" : "OFF");
handleState(res.output);
} else {
print("[ERROR] Could not read relay output state");
}
});
}
// ---------- Event handler ----------
Shelly.addStatusHandler(function (e) {
if (!e || !e.component) return;
if (e.component === "switch:" + CONFIG.local_switch_id) {
if (e.delta && typeof e.delta.output === "boolean") {
log("[EVENT] Relay changed to:", e.delta.output ? "ON" : "OFF");
handleState(e.delta.output);
}
}
});
// ---------- Startup ----------
print("[INIT] Relay mirror sender started");
readAndSendCurrentState();
The original guide with GUI starts here:
Step 1: Update the Firmware
It’s always a good idea to update the firmware to the latest version.
To do that, we need the devices to be connected to a Wi-Fi network with an internet connection.
Perform this step for all the devices.
1.
Log in to the device’s access point and enter its web interface by typing 192.168.33.1 in a browser.
![]()
Step 2: Setup Master. AP password and enable Range Extender
Step 3: Setup Slave. AP password and connect to the Master
Step 4: View devices connected to the range extender
Explanation
As You can se there are now two joined devices.
But we only joined one device?
For som reason, when enableing range extender on a device it shows itself as joind.
Look for the MAC adress to find wich one is the slave device.
You should then be able to copy the internal IP address and paste it into a new browser window to access the slave’s web interface while you are connected to the master.
From this info we now know wihch ip’s we should use for the Actions/webhook commands.
Master = 192.168.33.1
Slave = 192.168.33.3
Step 5: Example of multiway switching with actions
There is a lot of different ways You can control the light.
In the following example il’l show how simpel it is to do a multiway switching between 2 Shelly’s.
This way both shelly’s wil allways follow each others output status.
Note: If using a switch it needs to be replaced with a button or the switch should be converted to button with a spring.
1. Both Master and Slave needs to be set to Button-momentary input mode
2. Create actions on Master device
Go to Actions -> New Action – Select Output – Create action.
Create two actions.
When it’s ON then Turn Slave ON
When it’s OFF then Turn Slave OFF
Click here to view all the HTTP commands
Turn Slave ON, when output of master is ON
- Give it a Name.
- Execute when: Select “Switch toggled on”
- Then do: click on “+ Add URL” and add the http command for turning on the slave device.
http://192.168.33.3/relay/0?turn=on
Turn Slave OFF, when output of master is OFF
- Give it a Name.
- Execute when: Select “Switch toggled off”
- Then do: click on “+ Add URL” and add the http command for turning on the slave device.
http://192.168.33.3/relay/0?turn=off
3. Create actions on Slave device
Go to Actions -> New Action – Select Output – Create action.
Create two actions.
When it’s ON then Turn Master ON
When it’s OFF then Turn Master OFF
Click here to view all the HTTP commands
Turn Master ON, when output of Slave is ON
- Give it a Name.
- Execute when: Select “Switch toggled on”
- Then do: click on “+ Add URL” and add the http command for turning on the Master device.
http://192.168.33.1/relay/0?turn=on
Turn Master OFF, when output of Slave is OFF
- Give it a Name.
- Execute when: Select “Switch toggled off”
- Then do: click on “+ Add URL” and add the http command for turning on the Master device.
http://192.168.33.1/relay/0?turn=off
Step 6: You are done
It was that easy!















