Announcement

Collapse
No announcement yet.

Repeated use of CAPI causes HSPro to lock up

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Repeated use of CAPI causes HSPro to lock up

    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?


    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;
    }

    #2
    What version of HS3 are you running and on what type of system? There are other reports of memory leaks with C# scripts which was supposedly fixed in one of the later versions? You may want to write it as a vb.net script instead as there are no known leaks with it. Looking at the script, it should be a simple conversion.

    Cheers
    Al
    HS 4.2.8.0: 2134 Devices 1252 Events
    Z-Wave 3.0.10.0: 133 Nodes on one Z-Net

    Comment


      #3
      It's a HomeTroller Zee. Current version is: HS3 ZEE S2 Edition 3.0.0.313

      I just installed the 313 update this morning and I don't recall what version it was at before. I'll start the color changer now and see if it keeps running.

      This is going to snobbish (probably because it is), but I write software for a living and I don't think I could bring myself to write VB. :-)

      I was even thinking about writing a HS Plugin in F# just to see if I could.

      Thanks for the help. I'll post my results after the test has run for a while.

      -- Marc

      Comment


        #4
        Just to close this off, version 3.0.0.313 seems to have resolved the problem.

        Thanks for the help.

        Comment

        Working...
        X