Last active
September 24, 2023 11:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
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
Debug output when calling innerFunction from the top (works as intended)