Jump to content

JakubS

Members
  • Posts

    1
  • Joined

  • Last visited

JakubS's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • Conversation Starter

Recent Badges

0

Reputation

  1. 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.
×
×
  • Create New...