-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config does not contain a settings object #323
Comments
Just looking at the code (Config.cpp, lines 246-263), it appears that the error message "Config does not contain a settings object" is thrown when trying to set config values but |
@exxamalte "Does the config file on your device contain a settings key initially?" Yes, this will be the case, but it is just the resulting error. Don't use |
I can confirm that custom settings does not work when the default values are set. It works fine when not using the default values. |
I can't reproduce. Sample sketch: #include <Homie.h>
HomieNode temperatureNode("temperature", "temperature");
HomieSetting<long> aSetting("a", "A");
HomieSetting<long> bSetting("b", "B");
void setup() {
Serial.begin(115200);
Serial << endl << endl;
Homie_setFirmware("temperature-setting", "1.0.0");
temperatureNode.advertise("unit");
temperatureNode.advertise("degrees");
aSetting.setDefaultValue(1);
bSetting.setDefaultValue(2);
Homie.setup();
}
void loop() {
Homie.loop();
} I initially set The |
@marvinroger: Thanks a lot for spending time testing this, and for the nice work with the whole framework! However I can reproduce the problem in two different ways (using ArduinoJson v2.8.4): Way 1:
Way 2:
I think both these two problems can be solved by adding an empty "settings" in the config.json if there are no settings or just default values. I believe this because as soon as you have one setting in the "settings" section of the config.json then all others settings can be set from MQTT, regardless if the setting exists or not. One solution would be to add something similar to this before line 369 in BootConfig.cpp: |
Suggestion: Change line 316 in Validation.cpp from: This might solve the problem that you cant enter a value without decimals as a double in the config app. (The value 1.0 will not work either...) |
Oh, okay. Your suggestion would work fine if everyone would load the configuration boot, but you can also manually flash the configuration file to the SPIFFS, so it won't work. This bug was introduced when making the |
I am not sure that I fully understand your question. |
Yes, this is what I meant! 😉 Great. |
You might get the possibility to flash configuration files without the settings section if you add something similar to what I suggested just before the validation. In this way you can skip the But as I said above, just remove the opportunity to have a configuration file without settings section is perfectly fine for me... Have you got the time to look into the suggestion about the double validation problem? |
I was coming here to report this as well! I deployed my Homie 2.0 nodes with default HomieSetting values with the notion that I could tweak them as needed, however now I can not because none of them have a "settings" key in config.json. I feel like Homie should not require the configuration file to have this key before it will allow writing to it. If you leave the settings the default during provisioning, you can't change them without editing the settings file somehow? Either BootNormal or Config::patch should allow the special case of patching in a NEW settings top-level key. This of course also begs the question how to get back the default values since you can't patch out any values, only change them. |
Note that in initial config (configuration mode/fresh reset) there must be a |
I ran into this problem and should be fixed in #458 |
@timpur and @Gulaschcowboy could we close this issue? Is it solved? |
I can confirm, that the config contains the settings object with current develop branch. |
The error still occurs if you add settings after initial configuration. |
Hi @marvinroger et al.
I have defined 4 custom settings and I can't update them via MQTT nor via App/Web. To narrow down the issue I tried same with your CustomSettings example. If I don't change it and keep just 1 custom setting I can update the settings with :
mosquitto_pub -h broker -t "homie/test-3/$implementation/config/set" -u user -P pass -m '{"settings":{"temperatureInterval":30}}' -r
As soon as I add my settings it fails. After publishing with the above command I get
✖ Config does not contain a settings object
✖ Configuration not updated
in serial monitor.
See my modified CustomSettings example attached
test-settings.ino.txt
Update:
I could narrow it down further. If I don't set more than 1 value as default, all values become settable.
Thank you
Alex
The text was updated successfully, but these errors were encountered: