shelly-homekit
shelly-homekit copied to clipboard
Console error when clicking the "Setup" button on a Shelly i3
- Just update from the latest Shelly stock firmware to (2.11.2): http://x.x.x.x/ota?url=http://rojer.me/files/shelly/shelly-homekit-ShellyI3.zip;
- Disabled input 2 and 3;
- Clicked on the Setup button (from Chrome) and got:
Uncaught TypeError: Cannot read properties of undefined (reading 'toLowerCase') at el.onclick ((index):1424:27)
Which is the last line of:
el("hap_setup_btn").onclick = function() {
el("hap_setup_spinner").className = "spin";
// Generate a code from device ID, wifi network name and password.
// This way it remains stable but cannot be easily guessed from device ID
// alone.
let input = lastInfo.device_id + (lastInfo.wifi_ssid || "") +
(lastInfo.wifi_pass_h || "");
let seed = sha256(input).toLowerCase();
Please help. Happy to test something!
Exactly the same error with 2.10.1 but on a different line.
Uncaught TypeError: Cannot read properties of undefined (reading 'toLowerCase') at el.onclick ((index):1132:27)
These are the relevant values used in variable input received over RPC. Maybe it has to do with the less common characters in the SSID?
{
"id": 8583,
"src": "shellyix3-E8DB84D29388",
"result": {
"device_id": "shellyix3-EADB84D29388",
"wifi_ssid": "ευχαριστια (2,4 GHz)",
"wifi_pass_h": "531c54f836448b73c580bbacae32bd23"
}
}
The non ASCII characters in SSID are definitely the cause of this bug as the sha256 function uses https://github.com/geraintluff/sha256 which mentions:
Input must be an ASCII string - if character codes outside the range 0-255 are received, undefined is returned.
What about:
- Instead of
wifi_ssiduse a key likemac_addressorwifi_conn_ipas we know for sure that these keys will only contain ASCII values; - Test if the SSID is a valid ASCII string before using it in
input:
function isASCII(str) {
return /^[\x00-\x7F]*$/.test(str);
}
- Remove
wifi_ssidfrominputvariable.
This issue is stale because it has been open 3 weeks with no activity. Comment or this will be closed in 1 week.
We already hat that issue multiple times, so we should take a deeper look on that. Not sure on the impact on existing setups and about maybe needed changes in the C code.
If you use option 2, nothing would change in existing setups. I tested option 3 on ShellyI3, Shelly25 & ShellyPlugS and works fine.