Repository: homieiot/homie-esp8266

Issue #354: Homie 2.0: Create an option for boot normal mode
Created: 2017-06-08T14:22:15Z
I am building an IoT irrigation controller for the garden, based on MQTT. It is, basically, an standalone device that should work by itself when the network is not available. Of course the design expects a network and all interaction with the irrigation controller (i.e. programming irrigations, setting times, etc.) is done via MQTT and needs network connection. But it the network fails, the controller must continue doing its job and all scheduled irrigations should be done.
I have in operation in my garden an initial version of this irrigation controller and I was trying to implement OTA update when I found your Hoime project. By the way, Homie is an excellent project!! Congratulations!. As Homie fits perfectly for all other devices I have to develop my plan is to use Homie for them. And so, I decided to study the convenience of preparing a version of my irrigation controller based on Homie. It will cost me more or less the same than developing my own OTA update code. Therefore as my controller is a class, I derived it from HomieNode and removed some unnecesary services (basically dealing with network and MQTT connections). In a couple of days the irrigation controller was operational as a Homie node.
Now I am evaluating if definitelly the irrigation controller device should follow this approach (the irrigation controller as a Homie node) or better continue with my previous approach (code independent from Homie, but MQTT messages compatible). The main drawback for moving the irrigation controller to Homie is that in Homie the nodes in a device do not receive service (their loop method is not invoked) when the network connection is lost. And this is a serious problem for me, as LAN connectivity can be lost by many reasons but the important thing is that irrigations must continue according to the scheduled programs. Network connectivity is just a commodity for supervising the device operation (feedback received via MQTT) or for changing operational parameters via MQTT (setting irrigation programs, times, etc.). Not having connectivity it is not a serious problem for stopping irrigations.
The Standalone boot mode is not of use in this case, as it assumes no network connection.
What I really need is that in normal boot mode, in case of no connectivity, the Nodes::loop() method should be invoked so that the irrigation controller can do its job (but as there is no connectivity it will not send MQTT feedback to the domotic controller).
This would require a modification in BootNormal.cpp, just to remove the loop:
for (HomieNode* iNode : HomieNode::nodes) {
   iNode->loop();
 }

from inside the if statement:
if (Interface::get().connected) {
 }


But as this would create incompatibilities with existing software using Homie, I would suggest to create either a new boot node (NORMAL_STANDALONE) or an option for boot normal method. Would that be posible?
Thank you.

Duplicate issue #487: loopHandler not called until Homie is connected
Created: 2018-02-11T14:11:00Z
My device registers a loopHandler with setLoopFunction() and does all its work within that loopHandler.
Now I want my device in a "boot" mode until the WLAN is connected.
Having this code:
void loop() {
    if(Homie.isConfigured() && !Homie.isConnected()){
        layt->setBootMode(bm);
        loopHandler();  // this is neccessary !!!
    }
    else{
        layt->setBootMode(0);
    }
    Homie.loop();   
    delay(1);
}

I needed to add the line with "loopHandler()" in the main loop to be called when the WLAN is not connected in order to have my code in loophandler() beeing called.
In my opinion Homie.loop() should call the handler which has been set using setLoopFunction() in all cases. Or, did I miss something in the documentation?
With regards
Joachim

Closing comment (2018-02-11T14:32:57Z): This is related to #354