Created
March 9, 2026 20:43
-
-
Save mawmawmawm/926e522e3fb48fc8ce1175a6a5e62c30 to your computer and use it in GitHub Desktop.
Shelly Detached
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let switchId = 0; | |
| let url = 'http://10.10.10.10:8123'; | |
| function check(event) { | |
| Shelly.call("HTTP.GET", {url: url, body:{}, timeout: 2 }, function(resp) { | |
| let reachable = (resp && resp.code === 200); | |
| if (!reachable) { | |
| print("override switch behaviour"); | |
| Shelly.call("Switch.Set", { id: event.id, on: event.info.state }, function(){}); | |
| } | |
| }); | |
| } | |
| Shelly.addEventHandler(function(event) { | |
| if (event.name === "input" && event.id === switchId) { | |
| check(event); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment