Skip to content

Instantly share code, notes, and snippets.

@anttikuuskoski
Last active September 24, 2023 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anttikuuskoski/e1e515d2d4597a40b0fcd56dc41ffbe5 to your computer and use it in GitHub Desktop.
Save anttikuuskoski/e1e515d2d4597a40b0fcd56dc41ffbe5 to your computer and use it in GitHub Desktop.
Code to demonstrate a bug in shelly gen2 firmware 1.0.0-beta6 - 1.0.3 running in Shelly Plug Plus S wherein 2 levels of function calls prevents correct behaviour
function reportConfigError(res, ec, em) {
console.log("Config update error", ec, em);
}
let bluConfig = {
leds: {
mode: "switch",
colors: {
"switch:0": {
on: {
rgb: [ 0, 0, 100],
brightness: 80 },
off: {
rgb: [ 0, 50, 0 ],
brightness: 10 }
},
power: { brightness: 100 }
},
night_mode: {
enable: false,
brightness: 100,
active_between: [
"00:00",
"00:00"
]
}
},
controls: {
"switch:0": {
in_mode: "momentary"
}
}
};
function innerFunction() {
Shelly.call( "PLUGS_UI.SetConfig", { config: bluConfig }, reportConfigError );
}
function outerFunction() {
innerFunction();
}
//innerFunction(); // Works as intended - leds change color to blue
outerFunction(); // PLUGS_UI.SetConfig Fails with error code -103
@anttikuuskoski
Copy link
Author

anttikuuskoski commented Aug 11, 2023

Debug output when calling innerFunction from the top (works as intended)

shelly_user_script.:370 Running 'script_8.js'... 17:25:10
shelly_ejs_rpc.cpp:41 Shelly.call PLUGS_UI.SetConfig {"config":{"leds":{"mode":"switch","colors":{"switch:0":{"on":{"rgb":[0,0,100],"brightness":80},"off":{"rgb":[0,50,0],"brightness":10}},"power":{"brightness":100}},"night_mode":{"enable":false,"brightness":100,"active_between":["00:00","00:00"]}},"controls":{"switch:0":{"in_mode":"momentary"}}}} 17:25:10
shelly_user_script.:341 JS RAM stat: after user code: 101356 after: 97568, used: 3788 17:25:10
shelly_notification:163 Status change of script:8: {"id":8,"running":true} 17:25:10
shos_rpc_inst.c:230 PLUGS_UI.SetConfig via loopback 17:25:10

@anttikuuskoski
Copy link
Author

DebuDebug output when calling outerFunction from the top:

shelly_user_script.:370 Running 'script_8.js'... 17:14:16
shelly_ejs_rpc.cpp:41 Shelly.call PLUGS_UI.SetConfig {"config":{"leds":{"mode":"switch","colors":{"switch:0":{"on":{"rgb": ... ,"brightness": ... },"off":{"rgb": ... ,"brightness": ... }},"power":{"brightness":100}},"night_mode":{"enable":false,"brightness":100,"active_between":["00:00","00:00"]}},"controls":{"switch:0":{"in_mode":"momentary"}}}} 17:14:16
shelly_user_script.:341 JS RAM stat: after user code: 99148 after: 95376, used: 3772 17:14:16
shelly_notification:163 Status change of script:8: {"id":8,"running":true} 17:14:16
shos_rpc_inst.c:230 PLUGS_UI.SetConfig via loopback 17:14:16
Config update error -103 17:14:16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment