Fixed code of Smartnest and updated documentation#4001
Conversation
|
@Aircoookie & @Steven17D can you verify the changes please? This looks like a final version after much troubles. |
| ## Change log | ||
| 2022-09 | ||
| * First implementation. | ||
| 2024-05 |
There was a problem hiding this comment.
In changelog append the changes instead of removing the old log.
| lastMqttReport = currentMillis; | ||
|
|
||
| // Report current brightness | ||
| char brightnessMsg[6]; |
There was a problem hiding this comment.
Max %u output may be 4,294,967,295 which needs 11 characters (including \0)
| private: | ||
| bool initialized = false; | ||
| unsigned long lastMqttReport = 0; | ||
| unsigned long mqttReportInterval = 60000; // Report every minute |
There was a problem hiding this comment.
make this static const (or constexpr is better)
There was a problem hiding this comment.
I would argue to allow it to be just unsigned and use it as a run-time settable variable.
There was a problem hiding this comment.
So I better leave it like this?
There was a problem hiding this comment.
Better to add configuration item like other usermods.
| */ | ||
| void setup() { | ||
| // Initialization code here | ||
| if (!initialized) { |
There was a problem hiding this comment.
Why is initialized needed? This function is called once (isn't it?)
| 2. Use `#define USERMOD_SMARTNEST` in wled.h or `-D USERMOD_SMARTNEST` in your platformio.ini | ||
| 1. Use `#define USERMOD_SMARTNEST` in wled.h or `-D USERMOD_SMARTNEST` in your platformio.ini (recommended). | ||
| ## It is not necessary since the main branch of WLED brings it with it |
There was a problem hiding this comment.
If this is not necessary - remove
Sorry! I was on the wrong project branch, I'm sorry for the inconvenience! Now look |
Steven17D
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks for your contribution!
| DEBUG_PRINTF("Smartnest usermod setup initializing..."); | ||
|
|
||
| // Publish initial status | ||
| sendToBroker("report/status", "Smartnest usermod initialized"); |
There was a problem hiding this comment.
I know this is a bit late but I have figured out that WiFi is not yet configured let alone connected at the time of setup() call.
This call is pointless.
All problems were already corrected and working now.