Subject_Street_8814

Shelly i4 / Remote Relay

May 14th, 2025
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const sourceInputId = 0;  // If using multiple switches, update (0 is the first, 1 is the second, etc.)
  2. const sourceInputEventType = "single_push";  // single_push / long_push / double_push
  3. const targetSwitch = "0";  // Update if multiple outputs on the remote relay and it's not the first
  4. const httpIP = "10.1.1.1";  // update with the IP of your remote Shelly
  5. const httpPassword = "password";  // update with the web password for it
  6.  
  7. Shelly.addEventHandler(function (event) {
  8.     if (event.name === "input" && event.id === sourceInputId && event.info.event === sourceInputEventType) {
  9.         Shelly.call(
  10.             "HTTP.GET",
  11.             {
  12.                 "url": "http://admin:" + httpPassword + "@" + httpIP + "/relay/" + targetSwitch + "?turn=toggle"
  13.             }
  14.         )
  15.     }
  16. });
Advertisement
Add Comment
Please, Sign In to add comment