async-esp-fs-webserver icon indicating copy to clipboard operation
async-esp-fs-webserver copied to clipboard

Form option not saved (Thingsboard provisionning)

Open GregAscolab opened this issue 1 year ago • 1 comments

Hi,

I added Thingsboard provisionning option tab (and html page) to my setup (comes from example).
Provisionning API call works: I get the device_token, and it is displayed in the form.

But when I use the "save" button, it is not saved to the config.json file.

It seems that if I don't modify manually the form entry in the web page, modification are not detected, and not saved to file.

Please fix example, or give me a clue ;-)

GregAscolab avatar May 14 '24 13:05 GregAscolab

It seems that updating a value of an input in javascript doesn't fired "change" event...
(I'm not a javascript developer...)

So I found a workaround, by adding "option[]" update manually in javascript function, like it's done in the "change" event listener in all option input : options[token.id] = token.value;

In thingsboard.h, createNewDevice method :

...
.then(obj => {
    var token = $(TB_DEVICE_TOKEN);
    token.focus();
    token.value = obj.credentialsValue;
    options[token.id] = token.value; // Manual update, because, it doesn't fire "change" event...
    openModal('Write device attributes', 'Device provisioned correctly.<br>Do you want to set client attributes on ThingsBoard server?', setDeviceClientAttribute);
  });
...

Maybe not the best way, but it works.
If you have better solution, let me know.

GregAscolab avatar May 15 '24 09:05 GregAscolab

Hi and sorry for the huge delay in replying.

I had already noticed this problem. Basically if the value of the element is updated by the script, the change event is not triggered and therefore the value is not updated. I have not been able to find a valid workaround, but if yours works I will include it directly in the example.

cotestatnt avatar Aug 26 '24 13:08 cotestatnt