Advertisement
-Teme-

Detached when HA available

Dec 5th, 2024
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function testHA() { Shelly.call("HTTP.GET", {url: 'http://homeassistant.home:8123', body:{}, ssl_ca: '*'}, function(resp) {
  2.     let mode = (resp && resp.code === 200)? "detached" : "flip";
  3.     Shelly.call("Switch.GetConfig", {id: 0}, function(oldConfig) {
  4.       if (oldConfig.in_mode !== mode) {
  5.         Shelly.call("Switch.SetConfig", { id: 0, config: { in_mode: mode } });
  6.         if (mode === "detached") Shelly.call("Switch.Set", { id: 0, on: true });
  7.       }
  8.     });
  9.   })
  10. }
  11.  
  12. Timer.set((30 * 1000), true, testHA);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement