ESPHome to ESPHome direct communication?

thank you,
I was just looking for something like this,
Now I use Tasmota device grouping which is easier to setup as you don’t have to cross reference all devices, but this will do,

One question, Do you know if this also would be possible using the API?
For now I have the webserver enabled on all devices, but that’s basically for debugging, once I have ESPHome quirks under control I’m planning to remove the webServer

The rest api is part of the web server, so you’ll need the web server on the device you are controlling.

I actually mean this api.

Which can run even if webserver is disabled.

1 Like

So you want esp to esp via the native API? Not seen that done. Not sure it is even possible.

If I read the documentation the Native API seems to purely made for connecting and integrating with HA.
not sure this is possible,
I think I should go or the webapi as mentioned above.
I did some tests with postman and all works over there.

But I can’t find where/how to put the authentication credentials. I found that auth method is digest auth.
Still I think I need to specify the username and password somewhere.

The problem is,
the documentation suggests auth would mean basic authentication

but giving it a closer look, I looks like digest is uses,
for basic auth, I could just have encoded the credentials and send it in as header.
but Digest, which I’m not familiar with, seems to be a little more complicated and using http_request I can not find if it’s even possible to apply this,
maybe I should add this as a feature request.
a work around would be to remove the authentication, but I was just so happy that there was any.

If it’s using wifi, it should just as well communicate through home assistant. What I need is uart/i2c communication or actually using another esp/beken?? as a port expander, just like arduino port expander component. Using an esp32s2 that you have laying around(stupidly cheap) when you’re out of pins would be awesome.
Any suggestions?

use an i2c gpio expander… they are even cheaper than an esp32, they are smaller and you can chain many of them together to get dozens of additional gpio pins. The problem with using additional MCU boards for something simple like adding gpio pins is now you have to over complicate the project and essentially program 2 boards to communicate and work together to do a task that is easily doable with a single board. There isn’t anything awesome about complicating things that don’t need to be complicated and there. What is awesome though, is when you learn how to use a search box and you can find this stuff out all by your big boy self.

1 Like

This thread is about esphome to esp communication specifically and found it by…typing in a search box. Guys like you really like to take out the enthusiasm from noob looking users.

1 Like

Reminder:

1 Like

@wtv1211
I have developed components for simple direct communication via uart between 2 esphome devices. Try it out

4 Likes

I was looking at this and it looks interesting and could be useful to me. UART definitely isn’t a strong area for me so, i’ve been doing a little reading up on it. I didn’t see the max distance mentioned in your repo and looking online i’m seeing wildly different max distances from a couple of meters to 15 meters. What are the longest distances you have used? Also, I have quite a lot of shielded 6 conductor wire. Would shielded be better for longer distances or is interference not a big concern?

Thanks.

Twisted pair would be better.

I dont recall asking which is better, twisted or shielded. You know why. The 6 conductor are in twisted pairs with shielding. I was asking about distance and the risk factor of interference since im not using it in a commercial setting where its primarily used these days and interference is a factor in those settings. Thanks though, super duper helpful there bud.

@Fallingaway24
I have used it only with short distances max ~0.5m.
Which distances you need? Maybe I can test it if I have a cable that is long enough. :smiley:

There are off-the-shelf RS485 converters though which will handle long-distance and noise better: https://www.aliexpress.com/i/4001264234543.html

They should be pretty close to plug and play: connect your TTL UART to one side, RS485 cabling to the other.

Ive got the benefits of having 3 brothers that are all union electricians so i have all sorts of wire and can request it if not. I dont have any specific distances at the moment, I was more asking just to get an idea of the limitations. Just my personal opinion but, I think that would be useful information in your repo.

That’s very kind of you to offer to test it for me. I appreciate that but, i have the stuff to do it and cant ask you to do that for me or waste your materials. My hands arent broke and my Google-foo is strong, so i think i can handle it.

Ill have to double check my garage but, ive got some boxes of cat5 or cat6 and i dont recall the purpose of the other one but, i believe it was used for commercial automation/PLC’s its a 6 conductor with 3 twisted pairs of 24-26AWG with aluminum shielding and I think ill try both and report back what kind of information I find.

Thank you.

1 Like

This may be a dumb question so i apologize but, like i said initially, direct communication has never been something ive needed or thought i would and never bothered diving into it. Im pushing 45-50 esphome nodes so im wanting to eliminate some that are in close proximity or can be wired. So, what would be the pros and cons or use cases where something like this, uart would be preferred over something llike CAN bus? Or any other type of direct connection?

Looking at your original problem statement, it sounds like you don’t need ESPHome → ESPHome communication at all - you’re just trying to have a remote switch from the relay it controls.

So your only actual problem is pulling a wire from wherever the relay is back to where the switch is, and it can just be a dumb switch.

In my house I do this with athom mini-relay switches, the Sonoff equivalent would be this: MINIR4 - SONOFF Official

CAN bus make sense if you have multiple devices that need to connect each other. All devices have access to each message. But you need additional hardware. UART is great for direct communication between 2 devices that are not far away and you don’t need additional hardware.

I use that to control my solar battery system with 3 esphome devices there are side by side. One of them is connected to the others. Works because the esp32 has 3 UARTs. The master needs some values from the other ones and I wan’t to prevent failures if the wifi connection lost.