homieiot / homie-esp8266

💡 ESP8266 framework for Homie, a lightweight MQTT convention for the IoT
http://homieiot.github.io/homie-esp8266
MIT License
1.36k stars 308 forks source link

Homie ESP-8266 is not working without wifi #536

Closed kmehran closed 5 years ago

kmehran commented 6 years ago

[...template with no change deleted...]

kmehran commented 6 years ago

I designed a wifi light-switch, based on Homie and Openhab Server, the first important function of each light switch is turning on and off the lights, but it cannot turn on/off the light during wifi/mqtt connection or even when one or both of them lost. One of the Most important matter about adding extra functionality or new technology to an old system (like Light Switch) is do not affect its basic function(s).

Alex9779 commented 5 years ago

I found this somewhere else here, maybe in another issue description, the solution is depending on your implementation that you run the loop where you handle the events the manual switch raises in the mail loop in addition to the Homie.loop(). Here an excerpt of one of my implementations:

void loop()
{  
  Homie.loop();

  button.tick();
}

In this firmware is use the lib "OneButton" for handling a button, it is a uplight control firmware and the uplight has one button where you can turn it on and off in addtion to control it with Homie. You can see the "loop" for handling the button events is also in the main loop where the Homie.loop() is too. So both are run and no matter how the Homie state is the button events are processed...

kmehran commented 5 years ago

Dear Alexander,

That should be my solution, thanks for your complete answer.

Regards, Kaveh.

Sent from my iPhone

On Oct 22, 2018, at 10:37 AM, Alexander Leisentritt notifications@github.com wrote:

I found this somewhere else here, maybe in another issue description, the solution is depending on your implementation that you run the loop where you handle the events the manual switch raises in the mail loop in addition to the Homie.loop(). Here an excerpt of one of my implementations:

void loop() {
Homie.loop();

button.tick(); } In this firmware is use the lib "OneButton" for handling a button, it is a uplight control firmware and the uplight has one button where you can turn it on and off in addtion to control it with Homie. You can see the "loop" for handling the button events is also in the main loop where the Homie.loop() is too. So both are run and no matter how the Homie state is the button events are processed...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

euphi commented 5 years ago

See here, how to change the Homie-ESP8266 sources to get your desired behavior:

https://github.com/homieiot/homie-esp8266/pull/490/files

https://github.com/homieiot/homie-esp8266/blob/4e1cfe583c1e067928f874ee7ef7e04b3dd4c8d0/src/Homie/Boot/BootNormal.cpp

Misiu commented 5 years ago

@euphi, as this is labeled with Feature_V3, does it means that this will be added to develop-v3 branch? I'm trying to build Wemos D1 based multi-relay switch and recently I found this repo. Because OpenHab support homie 3.x I want to use this library. As many wrote before sometimes we don't want to wait for MQTT to connect at the start, the most important thing is the working relay.

I've found an example that I want to use as a base for my sketch - https://github.com/homieiot/homie-esp8266/blob/develop-v3/examples/IteadSonoffButton/IteadSonoffButton.ino

How should I change it so that I can toggle replay when I don't have MQTT connected? Example showing such behavior would be awesome.

euphi commented 5 years ago

Closed with #490.