thenewwazoo / homebridge-lutron-caseta-leap

Homebridge support for Lutron Caseta Smart Bridge 2
Apache License 2.0
82 stars 28 forks source link

platform.ts#L225 - bridge.setMaxListeners(125 * this.secrets.size); #123

Closed scooter133 closed 1 year ago

scooter133 commented 1 year ago

https://github.com/thenewwazoo/homebridge-lutron-caseta-leap/blob/41c82e319621ae42c27b65d6f74ed787446e6193/src/platform.ts#L225

Current Line: bridge.setMaxListeners(125);

Needs to be like the reference on line 95 with the this.secrets.size: bridge.setMaxListeners(75 this.secrets.size);

I believe With this change both L95 and L225 can have the constant back to 75 vs 125. I've Changes my source to that and no longer get the Error. I was getting the error when I changed the line to : bridge.setMaxListeners(150); with (75 * this.secrets.size) I no longer get the Error.

I also believe that there is an issue with adding the emitters for Switches that are not supported. I do have over 150 Caseta Devices across 3 Bridges, though I only have maybe 50 Pico Remotes. If you are only listening for events from the Pico's I should not hit the 125 Limit from that 2nd setMaxListeners on L225. Changing that line to the above did remove the Error, but It must be adding listeners for the other devices to have hit that limit?

P.S. The Distribution for Beta1 is still referencing the code from May, I had to manually download the source to get th August revision of platform.ts and recompile to get the version with the 125 constant.

scooter133 commented 1 year ago

Digging deeper into why I was exceeding over 150 when I only have 50 some odd Picos. Is because each Pico has multiple buttons that its creating Listener events for. So for a standard 3 button Pico, it has 5 Buttons on it, that's 5 listener events per Pico3ButtonRaiseLower. 50 * 5 = 250 maxListeners. I'm no longer hitting the limit as I have 2 (of 3) Bridges that have only 10 devices total while the main bridge is more than 1/2 3BR Picos!

So I do not believe we can calculate the number of Listeners per bridge to be some constant.

I have setup the code running on my system to have an additional GlobalOption for maxEmitters. That code works fine. Though I don't have the Hombridge-UI working for that new number field option. It's only accessable via editing the config.

"options": { "maxEmitters": 270, "filterPico": false, "filterBlinds": true, "clickSpeedDouble": "default", "clickSpeedLong": "default" }

thenewwazoo commented 1 year ago

Okay, that makes sense. Over 50 Picos is ... a lot! 😆 There's gotta be some maximum, given the limits imposed by the Smart Bridge itself. AFAIK, the Smart Bridge Pro supports 75, times 5 buttons is 375, plus 25 more for good measure...