Skip to content

Conversation

@tscofield
Copy link
Contributor

Rapid state changes of the wall dimmer switch causes the code to fail. Additional try/catch statements prevent the code from crashing.

Rapid state changes of the wall dimmer switch causes the code to fail. Additional try/catch statements prevent the code from crashing.
@tscofield
Copy link
Contributor Author

I have been running this version of code for several months now with no code crashes.

@tscofield
Copy link
Contributor Author

What is required to get this pull request merged to the main branch?

Copy link
Collaborator

@taulfsime taulfsime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi,

can you post some example of the errors you are getting (with the original version of the script)?


Shelly.call("KVS.Set", kvpData, cb);
try {
Shelly.call("KVS.Set", kvpData, cb);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an async method, so it doesnt throw. Instead, any error is returned through the callback.

Copy link
Contributor Author

@tscofield tscofield Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spamming the buttons on two switches, after fixing the error that occurs from line 205/213, I get this exception

Exception shown by UI
✕ Uncaught Error: Too many calls in progress at Shelly.call("KVS.Set", kvpData, cb); ^ in function "updateLocalKVS" called from updateLocalKVS(currentStatus); ^ in function called from system

Additional details from logs output
Running setLocalDimmerStatus 01:03:30 {"on":true,"brightness":3} 01:03:30 Error: Set light status: Error: Error: Too many calls in progress 01:03:30 Status Handler intercept : {"component":"sys","name":"sys","id":-1,"delta":{"kvs_rev":188}} 01:03:30 Key Value Store has been updated 01:03:30 Update local setting 01:03:30 Running UpdateLightState: 01:03:30 ^ 01:03:30 in function "updateLocalKVS" called from updateLocalKVS(currentStatus); 01:03:30 ^ 01:03:30 in function called from system

// Send data to all remote (skip the local IP)
if (CONFIG.dimmerGroup[i] !== CONFIG.wifiIP) {
currentStatus.ip = CONFIG.dimmerGroup[i];
syncKVSToDimmer(currentStatus);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have those detail any longer. I'll have to see if I can reproduce, most of the testing that revealed where to add the try statements dealt with hitting multiple switches repeatedly.

@tscofield tscofield requested a review from taulfsime November 29, 2025 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants