I understood that the best communication option would be through MQTT.
I installed and configured the MQTT add-on, I did port forwarding from the router to the ip of the raspberry pi, with port 1883, I checked the status of the port, it is open. But with all that I can’t connect when I try to configure MQTT explore and I don’t understand where the problem is.
I did exactly the same steps as the guy in this video, plus port forwarding from the router https://www.youtube.com/watch?v=vZLvEwwpPkU
OK. It seems I misunderstood.
It seems that I can connect from the local network.
But I need this connection to use it outside the local network, more precisely I want to add a Wemos D1 mini, in this HA, but which is outside the locality, connected to another WiFi network. How can I do this?
First of all check if the port forwarding is working with any online tool to see if the port is open from outside your network.
Then use https://mqtt-explorer.com/ to see if you can login
I have been struggling since morning to solve this problem.
In the end, I managed to create the connection by replacing the Raspberry IP with the dns from homeassistant which is done through DuckDNS.
So as not to open another topic.
I managed to create the broker, as I said above.
And now I’m trying to connect a wemos d1 mini to that broker, but regardless of the settings I make in the yaml file, I get this error.
[I][mqtt:234]: Connecting to MQTT...
[W][mqtt:323]: MQTT Disconnected: TCP disconnected.
[I][mqtt:234]: Connecting to MQTT...
[W][mqtt:323]: MQTT Disconnected: TCP disconnected.
[I][mqtt:234]: Connecting to MQTT...
[W][mqtt:323]: MQTT Disconnected: TCP disconnected.
[I][mqtt:234]: Connecting to MQTT...
[W][mqtt:323]: MQTT Disconnected: TCP disconnected.
[I][mqtt:234]: Connecting to MQTT...
[W][mqtt:323]: MQTT Disconnected: TCP disconnected.
[I][mqtt:234]: Connecting to MQTT...