Closed dzungpv closed 4 years ago
@gysmo38 if server down for more than 50 millisecond, you code will work as standalone and not retry to connect to MQTT server, you set mqtt_config to false and loop code not running after https://github.com/gysmo38/mitsubishi2MQTT/blob/f5d81882f5d84508f416563e264c76e524beb237/src/mitsubishi2mqtt/mitsubishi2mqtt.ino#L963.
With my auto connect after 15 minutes code, it will retry after failed first time after 15 minutes and try for 50 millisecond like your code and then repeat endlessly. So when server down user will not need to enter config page to reboot it for reconnect MQTT server, or the device not hang for user fix their config in the UI.
On the setup i set lastMqttRetry=0 so in the the loop:
if ((millis() > (lastMqttRetry + MQTT_RETRY_INTERVAL_MS)) or lastMqttRetry==0){
mqttConnect();
}
mqttConnect(); run as before until mqtt connect failed (retry 5 times) when i set lastMqttRetry = millis(); later that if mqtt still not connect i will retry every 15 minutes
@gysmo38 So i reduces it to 1 seconds. I test disconnect the MQTT server and web control still work fine.
@dzungpv I tested with my code and if I shutdown MQTT server and start MQTT, it reconnect well. So I don't think a timer is necesery. I try 5 time and give up to reconnect until the next time loop() is call.
@dzungpv I tested with my code and if I shutdown MQTT server and start MQTT, it reconnect well. So I don't think a timer is necesery. I try 5 time and give up to reconnect until the next time loop() is call.
I also test web UI control, with your code it still reconnect to MQTT server after disconnect but it block the UI, it still working but not so responsive. So with delay 1 second, the CPU less busy and can work as standalone mode normal.
Will this solve the 26 degrees current-temp in HA? Keep up the good work both of you !!
OK I accept this change but not sure about the timer. If I get issue I will go back for this part.
I add some improvement: