-
Notifications
You must be signed in to change notification settings - Fork 86
Add additional try catch statements #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,7 +74,11 @@ function updateLocalKVS(currentState, cb) { | |
| value: createLightValue(currentState), | ||
| } | ||
|
|
||
| Shelly.call("KVS.Set", kvpData, cb); | ||
| try { | ||
| Shelly.call("KVS.Set", kvpData, cb); | ||
| } catch (err) { | ||
| console.log(err) | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -113,13 +117,17 @@ function syncKVSToDimmer(currentItem) { | |
| // Loop through all the dimmers and send the KVS update | ||
| // This should only be called once a value has changed | ||
| function syncKVSToAll(currentStatus) { | ||
| for (let i = 0; i < CONFIG.dimmerGroup.length; i++) { | ||
| // Send data to all remote (skip the local IP) | ||
| if (CONFIG.dimmerGroup[i] !== CONFIG.wifiIP) { | ||
| currentStatus.ip = CONFIG.dimmerGroup[i]; | ||
| syncKVSToDimmer(currentStatus); | ||
| try { | ||
| for (let i = 0; i < CONFIG.dimmerGroup.length; i++) { | ||
| // Send data to all remote (skip the local IP) | ||
| if (CONFIG.dimmerGroup[i] !== CONFIG.wifiIP) { | ||
| currentStatus.ip = CONFIG.dimmerGroup[i]; | ||
| syncKVSToDimmer(currentStatus); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| } | ||
| } | ||
| } catch (err) { | ||
| console.log(err); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // ****************************************************************** | ||
|
|
@@ -202,7 +210,7 @@ function setLocalDimmerStatus(value) { | |
| } | ||
| ); | ||
| } catch (err) { | ||
| console.log("Error: Set light status: ", err) | ||
| console.log("Error: Set light status: ", err); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -215,7 +223,11 @@ function createHandler() { | |
|
|
||
| if (event.name === 'light' && event.delta && event.delta.brightness !== undefined) { | ||
| console.log("Someone changed the brightness or pressed the light switch, syncing with the other switches"); | ||
| updateKVSState() | ||
| try { | ||
| updateKVSState(); | ||
| } catch (err) { | ||
| console.log(err); | ||
| } | ||
| } | ||
|
|
||
| // Update dimmer control data | ||
|
|
@@ -225,7 +237,7 @@ function createHandler() { | |
| try { | ||
| updateLightState(); | ||
| } catch (err) { | ||
| console.log(err) | ||
| console.log(err); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 systemAdditional 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