I have a Fibaro RGBW LED controller that I'm trying to control using the script below. The script changes the LEDs to a random color. It creates three random numbers for Red, Green and Blue and then randomly zeroes out one of those so that it only generates combinations of two colors (otherwise you get lots of washed out tints of off white). It uses CAPIGetSingleControlByUse to get the dimmer controls for each color and then ControlValue to set the dimmer values.
I start a timer that causes this script to be executed once a minute. After a few hours of this running the colors stop changing. If I try to access the local HS web interface it hangs; the browser just sits and spins. The only option is to physically reboot the device.
I'm guessing that it's leaking memory because I missed cleaning up something in the CAPI but I haven't been able to find it.
Any ideas?
I start a timer that causes this script to be executed once a minute. After a few hours of this running the colors stop changing. If I try to access the local HS web interface it hangs; the browser just sits and spins. The only option is to physically reboot the device.
I'm guessing that it's leaking memory because I missed cleaning up something in the CAPI but I haven't been able to find it.
Any ideas?
Code:
using System; using HomeSeerAPI; public Object Main(Object[] parm) { var devRed = hs.GetDeviceRefByName("First Floor Kitchen Cabinet LEDs Switch Multilevel Red"); var devGreen = hs.GetDeviceRefByName("First Floor Kitchen Cabinet LEDs Switch Multilevel Green"); var devBlue = hs.GetDeviceRefByName("First Floor Kitchen Cabinet LEDs Switch Multilevel Blue"); var ccRed = hs.CAPIGetSingleControlByUse(devRed, ePairControlUse._Dim); var ccGreen = hs.CAPIGetSingleControlByUse(devGreen, ePairControlUse._Dim); var ccBlue = hs.CAPIGetSingleControlByUse(devBlue, ePairControlUse._Dim); var rnd = new Random(); int[] values = { rnd.Next(255), rnd.Next(255), rnd.Next(255) }; var idx = rnd.Next(3); values[idx] = 0; ccRed.ControlValue = values[0]; ccGreen.ControlValue = values[1]; ccBlue.ControlValue = values[2]; hs.CAPIControlHandler(ccRed); hs.CAPIControlHandler(ccGreen); hs.CAPIControlHandler(ccBlue); return 0; }
Comment