JakubS Posted April 30 Share Posted April 30 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. Quote Link to comment Share on other sites More sharing options...
Dimitar Posted May 7 Share Posted May 7 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 ? 1 Quote Link to comment Share on other sites More sharing options...
Adi Posted June 30 Share Posted June 30 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! Quote Link to comment Share on other sites More sharing options...
JakubS Posted July 4 Author Share Posted July 4 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). 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). Quote Link to comment Share on other sites More sharing options...
Members thgoebel Posted July 4 Members Share Posted July 4 This seems to be possible with a Shelly plus RGBW PM: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.