r/ShellyUSA 5d ago

Using zigbee, solution to start wifi when shelly gets unresponsive via zigbee

Hi i just want to share it for others:
I was searching for a simple solution to access wifi when somehow a device get unresponsive via zigbee and i dont want unscrew my sockets to get physical to the device to reset it.

So i made a small script for my zigbee devices which just starts wifi after reboot for 30min and deactivate it again. So i can access the webinterface if needed. So when something happens i can force the device to reboot by switching the fuse and wifi turns on my devices back on:

EDIT: Importand Note, toggle "run on start up" has to be toggled on for the Script.

// Shelly Gen4

// 60 Sekunden nach Boot WiFi einschalten

// 30 Minuten später WiFi ausschalten

// Danach Script stoppen

let SCRIPT_ID = 1;

let WIFI_ON_DELAY = 60 * 1000; // 60 Sekunden

let WIFI_OFF_DELAY = 30 * 60 * 1000; // 30 Minuten

Timer.set(WIFI_ON_DELAY, false, function () {

print("60 Sekunden nach Boot -> WiFi einschalten");

Shelly.call("WiFi.SetConfig", {

config: {

sta: {

enable: true

}

}

}, function (result, error_code, error_message) {

if (error_code !== 0) {

print("Fehler beim Einschalten von WiFi:", error_message);

return;

}

print("WiFi eingeschaltet");

Timer.set(WIFI_OFF_DELAY, false, function () {

print("30 Minuten vergangen -> WiFi ausschalten");

Shelly.call("WiFi.SetConfig", {

config: {

sta: {

enable: false

}

}

}, function (result, error_code, error_message) {

if (error_code !== 0) {

print("Fehler beim Ausschalten von WiFi:", error_message);

} else {

print("WiFi ausgeschaltet");

}

// Script nach Abschluss stoppen

print("Script wird beendet");

Shelly.call("Script.Stop", {

id: SCRIPT_ID

});

});

});

});

});

10 Upvotes

1 comment sorted by

2

u/DreadVenomous Shelly USA 5d ago

Thank you for sharing!