Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mawmawmawm/926e522e3fb48fc8ce1175a6a5e62c30 to your computer and use it in GitHub Desktop.

Select an option

Save mawmawmawm/926e522e3fb48fc8ce1175a6a5e62c30 to your computer and use it in GitHub Desktop.
Shelly Detached
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