feature-requests icon indicating copy to clipboard operation
feature-requests copied to clipboard

[Feature Request] for Cloudflared tunnel support

Open deanfourie1 opened this issue 2 years ago • 17 comments

Would love to see integration for the ESPhome project and ESP32 to support the possiblity to connect to a cloudflared tunnel. Not sure how possible this is to achieve, but I have a use case scenario where I want to use a ESP32 to connect and send MQTT over WAN on a different network / 4G, but cannot open port due to CGNat.

Allowing ESPhome to connect the ESP to a cloudflared tunnel would be pretty awesome!

deanfourie1 avatar May 04 '23 00:05 deanfourie1

bump

deanfourie1 avatar May 14 '23 07:05 deanfourie1

This would be amazing. Imagine if you could have an URL entry in your YAML pointing to your external home assistance instance. PLEASE DO THIS.

PablexXXXX avatar May 16 '23 00:05 PablexXXXX

ESPHome Cloudflare tunnel.

PablexXXXX avatar May 16 '23 00:05 PablexXXXX

As described in a similar request this the challenge is that the ESPHome device is the server not the HA so the ESPHome device would need to setup the tunnel not the other way around. to be able to expose the ESPHome device you would need it to run the cloudflared tunnel code on the ESP and then create a new DNS endpoint. You would then need to point your home assistant server at the new end point.1) I am not sure that the ESP32 is powerfull enough to run that code and 2) A solution for remote and encrypted communication already exists, if you want to do remote ESP home devices it would be best to use encrypted/authenticated MQTT that is pointed at a public MQTT broker then connect your HA instance to liten to that MQTT server, this still solve the "anywhere" challenge of deploying an ESPHome device with components that are already in place.

Ralphy140 avatar May 23 '23 01:05 Ralphy140

Yes but in order to setup remote MQTT you will need to have MQTT port open server side.

This is not possible for those behind CGNat.

The idea of the esp32 creating the tunnel is seemless,

It executes the connection and creates the tunnel,

The the cloudflare routing handles the rest, routing between other tunnels etc to reach the HA instance.

This is what would make this integration so awesome.

deanfourie1 avatar May 23 '23 01:05 deanfourie1

In this architecture you would use a public MQTT broker like hivemq, You would connect both the endpoint of the ESP and the HA server to it. Then it will do MQTT message exchange without ether device being public. I am not proposing that you make your HA server public

Ralphy140 avatar May 23 '23 02:05 Ralphy140

Cloudflared is "public" too... They do see inside your tunnels...

nagyrobi avatar May 23 '23 04:05 nagyrobi

I manage to expose my MQTT broker through the cloudflared tunnel, but only MQTT over WebSocket, which is not possible to use with ESPHome… so implementing MQTT over WebSocket in ESPHome could be a palliative to be able to use remote ESPHome devices even being in a CGNAT network (where it is not possible to expose ports) and not needing to depend on public brokers.

dougiteixeira avatar Jun 18 '23 10:06 dougiteixeira

This would be amazing.

Marckkill avatar Nov 25 '23 21:11 Marckkill

Dead thread; but did this ever come to life? Anyone find a way?

VishveshC avatar May 29 '24 04:05 VishveshC

Nah, sad :(

deanfourie1 avatar May 29 '24 12:05 deanfourie1

I manage to expose my MQTT broker through the cloudflared tunnel, but only MQTT over WebSocket, which is not possible to use with ESPHome… so implementing MQTT over WebSocket in ESPHome could be a palliative to be able to use remote ESPHome devices even being in a CGNAT network (where it is not possible to expose ports) and not needing to depend on public brokers.

Yes, I did the same. Support of WebSocket transport is the missing component and would be the excellent solution.

grest avatar Jun 25 '24 21:06 grest

But seriously, how hard could it be? I don't see it requiring a lot of resources on the esp to make this feature possible.

Cloudflare have all docs available for API. Just need some smart cookie to make it happen ;)

deanfourie1 avatar Jun 27 '24 12:06 deanfourie1

It would be a very useful twist

tux789-coder avatar Nov 02 '24 18:11 tux789-coder

This would be great

x10 avatar Jan 18 '25 18:01 x10

Really wish this was possible. It would make remote devices so so so easy to set up and deploy.

coltography avatar Mar 06 '25 22:03 coltography

This would be a game changer!

mat-lo avatar May 29 '25 08:05 mat-lo