ALLTERCO / shelly-script-examples

Shelly Scripts for Gen2 Shelly devices
Apache License 2.0
198 stars 55 forks source link

WIFI provisioning script - error encountered #77

Closed MoDo-git closed 5 months ago

MoDo-git commented 11 months ago

Received an error running this script on a ShellyPlus2PM:

this is the log: Uncaught ReferenceError: "self" is not defined at for (let papk in self.targetCache) { ^ in function "isInCache" called from if (self.isInCache(cSSID) === false) { ^ in function called from system

Seems like there is an issue here: https://github.com/ALLTERCO/shelly-script-examples/blame/297358ede3b448d683a90a6c301e2c82dfd02506/wifi-provision.js#L127-L134

The self variable is used, but it is not defined within the function's scope.

chrisharrison123 commented 6 months ago

hey, did you ever get to the bottom of this, I'm trying to get this working but have run into the same issue.

MoDo-git commented 6 months ago

Never ever got it working. Would be awesome feature if working!!

taulfsime commented 6 months ago

@MoDo-git @chrisharrison123 Could you please test this updated version of the script: https://github.com/ALLTERCO/shelly-script-examples/blob/fix-wifi-provision-example/wifi-provision.js

chrisharrison123 commented 6 months ago

Hi,

Iv been testing the updated script and from what iv found, the script now doesn’t seem to get caught by the “self cache” issue anymore, it connects to the target device but then I lose connection to it, presumably as its now connected to the target but the target never appears to get provisioned and then I cant access it until I reset the unit again. Is there anything that I’m supposed to configure in here before use?

Also as part of this id asked Chris that this script had a function inserting a preset MQTT configuration, the reason is that when a unit is connected to the wifi, it then connects to one of our MQTT brokers where it is reprogrammed via rpc messages.

Look forward to hearing back.

Thanks

Chris

Chris Harrison Technical Director 03330 341 312 | 07921800745 @. resicentral.co.uk From: taulfsime @.> Sent: Saturday, May 4, 2024 6:12 PM To: ALLTERCO/shelly-script-examples @.> Cc: Chris Harrison @.>; Mention @.***> Subject: Re: [ALLTERCO/shelly-script-examples] WIFI provisioning script - error encountered (Issue #77)

@MoDo-githttps://github.com/MoDo-git @chrisharrison123https://github.com/chrisharrison123 Could you please test this updated version of the script: https://github.com/ALLTERCO/shelly-script-examples/blob/fix-wifi-provision-example/wifi-provision.js

— Reply to this email directly, view it on GitHubhttps://github.com/ALLTERCO/shelly-script-examples/issues/77#issuecomment-2094306245, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BH24X3N6E7Z54G4XTXYDTZLZAUJHDAVCNFSM6AAAAAA7WETR7CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJUGMYDMMRUGU. You are receiving this because you were mentioned.Message ID: @.**@.>>