Hi everyone, the project is fantastic and adapting it worked right away.
I adapted to my purpose by simply trying to automatically return the swich after activating it I modified switch 1 in this way to create a restart
if (topicStr == "/house/switch1/")
{
//turn the switch on if the payload is '1' and publish to the MQTT server a confirmation message
if(payload[0] == '1'){
digitalWrite(switchPin1, LOW);
client.publish("/house/switchConfirm1/", "1");
delay(1000);
digitalWrite(switchPin1, HIGH);
client.publish("/house/switchConfirm1/", "0");
client.publish("/house/switch1/", "0"); //Duplicated for desperate attempt
Serial.print("ESP RESTART");
}
later I will replace Serial.print (āESP RESTARTā); with the ESP.restart () line;
The swich works partly because when the trigger turns on and off correctly, but if I press the reset button or in any case restart the card, after connecting to MQTT it finds a payload at 1 and triggers it.
I discovered this by doing several debugging on the outputs at various stages of the sketch and there I found that immediately after rebooting the board finds a payload 1
After this first click it works correctly, but in my case with a restart it would enter an infinite restart loop.
Why after rebooting it reads a payload at 1 ?? I lost 2 full days with no results
Is there something in what I added or is there an option to clean the payload?
My output serial monitor after reload:
Topic: /house/switch1/
/house/switch1/
49 <----print of payload[0]
1ch4/ <----print of payloadStr created with String payloadStr = String(( char *) payload);
Hello Ady_soft
First of all, excuse my English.
I have the same problem as you on the serial monitor it always appears connecting ā¦
In addition, the buttons on the HA go crazy, if you turn them on they stay a few seconds in blue and then they turn off by themselves.
So far I couldnāt find the error.
could you solve it?
Can you help me?
Thank you and I hope your answer.
Gerardo
I learned in 3 days how to setup the MQTT, using binary sensors and switches just searching and reading. Not all instruction works because of the Hass versions.
I hope this will help beginners, is not a plug and play solution need some knowledge, even me Iām learning every day something new.