homie-esp8266 icon indicating copy to clipboard operation
homie-esp8266 copied to clipboard

settings section for defaulted custom settings not created by ui_bundle

Open mosseb opened this issue 5 years ago • 2 comments

Hi. I have 2 custom settings like that :

upCourseTimeSetting.setDefaultValue(SHUTTER_COURSETIME_MAX).setValidator(validator);
downCourseTimeSetting.setDefaultValue(SHUTTER_COURSETIME_MAX).setValidator(validator);

Initially I manually add an empty settings section in the JSON config that I upload via SPIFFS. Then I use MQTT message to populate the values. So far so good.

In the case the configuration goes in an unwanted state (wrong manipulation), I implemented a way to reset the module to default settings, by issuing a Homie.reset(); It restarts, goes into configuration mode and spawns the AP. I enter all the needed informations, it reboots... And unfortunately, the settings section is lost and doesn't exist anymore in $implementation/config

And I cannot add it again because of the error : ✖ Config does not contain a settings object

I would expect the both things to be possible :

  • I can add a custom settings to the JSON settings by passing it on the $implementation/config/set topic
  • ui bundle add the section automatically when detecting some custom settings
  • Or maybe the simplest solution would be to always add an empty settings section at boot if it does not exist, or remove the "config does not contain a settings object" error and actually add it instead.

Not that if I remove setDefaultValue, the UI bundle forces to enter a value and correctly creates the settings section.

Thanks !

mosseb avatar Jun 03 '20 21:06 mosseb

A fix for this patching issue is currently included in the develop branch, so try to use this if feasible.

mkfrey avatar Jun 04 '20 13:06 mkfrey

Confirm, It works on develop branch :+1:

Thanks!

elbowz avatar Sep 02 '21 13:09 elbowz