Jump to content
Gen2 Devices: FW Update Required / Gen2 Geräte: FW-Update erforderlich ×

Color mixer with Shelly Plus i4 & Shelly RGBW2


JakubS

Recommended Posts

Hello everyone,

I'm trying to code a color mixer with i4 & RGBW2. When one of the buttons on i4 is pressed, one of the channels on RGBW2 should start to increase it's brightness.

var red = 0;
var blue = 0;
var green = 0;
var input;
 

//code sniphet that check which input is currently pressed

//tried to make a function with input parameters if(e.component === "input:" + input), so I wouldn't have to else if it, but that didn't work. 


  Shelly.addStatusHandler(function(e) {
    if (e.component === "input:0") {
      if (e.delta.state === true) {
        input = 0;
      }
    }
    else if (e.component === "input:1") {
      if (e.delta.state === true) {
        input = 1;
      }
    }
    else if (e.component === "input:2") {
      if (e.delta.state === true) {
        input = 2;
      }
    }
  });

}

 

//this function only adds RGB 0 0 0
function RGBIncrease() {
    Shelly.addStatusHandler(
      function(e) {
        if (e.component === "input:0") {
          if (e.delta.state === true) {
            if(green < 255) {
              green ++;
              }
            } 
          }
        
        else if (e.component === "input:1") {
          if (e.delta.state === true) {
            if(blue < 255) {
              blue ++;
              }
          }
        }
        else if (e.component === "input:2") {
          if (e.delta.state === true) {
            if(red < 255) {
              red ++;
              }
          }
        }
       }
     );
  Shelly.call(
      "HTTP.POST", {
        "url": "http://10.66.0.163/color/0?",
        "body": "turn=on&red="+red+"&blue="+blue+"&green="+green+"&gain=100"
      }
     );
}

Timer.set(
    /* number of miliseconds */ 500,
    /* repeat? */ true,
    /* callback */ RGBIncrease
  );

 

 

The problem is that the script runs for 2 seconds and then I get an error message "Uncaught Error: Too many subscriptions".

My suspisions are that I have somewhere a memory leak or I'm exceeding the device limit and it can't handle it (maybe too many calls). 

Either way any advice helps.

Link to comment
Share on other sites

On 4/30/2024 at 5:12 PM, JakubS said:

Hello everyone,

I'm trying to code a color mixer with i4 & RGBW2. When one of the buttons on i4 is pressed, one of the channels on RGBW2 should start to increase it's brightness.

var red = 0;
var blue = 0;
var green = 0;
var input;
 

//code sniphet that check which input is currently pressed

//tried to make a function with input parameters if(e.component === "input:" + input), so I wouldn't have to else if it, but that didn't work. 


  Shelly.addStatusHandler(function(e) {
    if (e.component === "input:0") {
      if (e.delta.state === true) {
        input = 0;
      }
    }
    else if (e.component === "input:1") {
      if (e.delta.state === true) {
        input = 1;
      }
    }
    else if (e.component === "input:2") {
      if (e.delta.state === true) {
        input = 2;
      }
    }
  });

}

 

//this function only adds RGB 0 0 0
function RGBIncrease() {
    Shelly.addStatusHandler(
      function(e) {
        if (e.component === "input:0") {
          if (e.delta.state === true) {
            if(green < 255) {
              green ++;
              }
            } 
          }
        
        else if (e.component === "input:1") {
          if (e.delta.state === true) {
            if(blue < 255) {
              blue ++;
              }
          }
        }
        else if (e.component === "input:2") {
          if (e.delta.state === true) {
            if(red < 255) {
              red ++;
              }
          }
        }
       }
     );
  Shelly.call(
      "HTTP.POST", {
        "url": "http://10.66.0.163/color/0?",
        "body": "turn=on&red="+red+"&blue="+blue+"&green="+green+"&gain=100"
      }
     );
}

Timer.set(
    /* number of miliseconds */ 500,
    /* repeat? */ true,
    /* callback */ RGBIncrease
  );

 

 

The problem is that the script runs for 2 seconds and then I get an error message "Uncaught Error: Too many subscriptions".

My suspisions are that I have somewhere a memory leak or I'm exceeding the device limit and it can't handle it (maybe too many calls). 

Either way any advice helps.

@Kristian Todorov can you help there ?

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Unfortunately, there are few discussions on such an interesting topic as the interaction between i4 and RGBW2.

In the unavailability of mobile devices, the i4 is probably the only available way to control the RGBW2 controller.

I encourage connoisseurs and active forum members to bring more attention to this topic!

Link to comment
Share on other sites

On 6/30/2024 at 5:08 PM, Adi said:

the i4 is probably the only available way to control the RGBW2 controller.

Yes, that was my initial thought.

Another idea was with Shelly UNIs that read % input value from some kind of sliders/dials (see img). 

BRASS DIMMER SWITCH / 4G LIGHT DIMMER SWITCH / BRASS KNURLED

Each dial for one color.

 

With this solution, the scripting would be much easier. But again, might be problem with the device capabilities (too many calls or something like that).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Erstelle neue...