-
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
Use Homie Settings before Homie Setup? #372
Comments
Also wondering if its possible to set settings through code during running of homie with out going through mqtt? |
Yes, it is possible. But be careful when you use settings within a constructor (or anything called from a constructor) of a global or static object. See PR #335 for a solution to use HomieSetting in a constructor. |
@marvinroger, ideas? |
The problem is we're populating the settings objects at Sent from my Google Nexus 5X using FastHub |
Ah, yes. My PR #335 just makes it possible to add items to the vector |
I get that, in the same boat. TBH dont know much about the internals of homie, ill slowly learn how it all works so i can make more meaningful contributions. Thus dont really know what you guys are talking about sorry :P |
Could we have a Can you extract that part of the settings config code and use the settings objects like that, all before |
BTW: @marvinroger Can you merge my PR soon? It just changes a undefined (or random) behaviour to a defined one. |
I've beed struggling with this a lot. I'm subclassing Homie nodes which have custom properties. Example a Weather Underground Node that needs an API key, location etc. See log:
My solution is that I have introduced a
|
Any progress on this ? |
Added in v2.1 (not yet merged) Example of use (also in docs) HomieSetting<long> percentageSetting("percentage", "A simple percentage");
void SetupHomieSettings() {
percentageSetting.setDefaultValue(50).setValidator([](long candidate) {
return (candidate >= 0) && (candidate <= 100);
});
Homie.getLogger() << "percentageSetting Value: " << percentageSetting.get() << endl; // should be default
Homie.loadSettings();
Homie.getLogger() << "percentageSetting Value: " << percentageSetting.get() << endl; // should be config value
} I generally setup settings before nodes so i can use setting values in the setup of nodes. (this will make that even more possible !!!!) |
Seems to be stale issue. |
Is it possible to use homie settings before homie is setup.
Id like it use this to set a parameter used fro advertising a node attribute (which has to be done before homie setup...).
Thanks Tim.
The text was updated successfully, but these errors were encountered: