ESPHome to ESPHome direct communication?

Is it possible for one ESPHome device to talk directly with another ESPHome device?

My use case is I have a switch on a wall (Sonoff T1) and it’s controlling a relay (sonoff basic) located somewhere else in the house.
I currently have an automation in HA to get the status from the switch, and send it as a command to the sonoff basic, but this has some problems.
Namely if the MQTT server is down, or HA is down, it doesn’t work.

I see that ESPHome can subscribe to MQTT topics, which would cut out the middleman of HomeAssistant for this task, but is it possible to do this without MQTT as well, and have true point-to-point communication over WiFi between two ESPHome devices?

EDIT:

It seems that the answer is no, this is not currently possible, but there are two feature requests that would meet these needs, #57 and #52.

5 Likes

Why would you even ask that here? This is the home-assistant forum. Why would you come here asking how you can avoid using home-assistant?

A) This is posted in the ESPHOMELIB section

B) This forum is listed as the official ESPHOME forum on their website

Maybe you didn’t read closely, but that’s not what I asked.
The device Is still controlled via HomeAssistant, with HA controlling it based on motion and timers.
HomeAssistant is still very much involved in the control of these two devices, and would continue to be.

13 Likes

Hey. Love the response isn’t ESPHome used only with home assistant? At the moment.

Any ways blah blah blah

Try using ble first of all tracker and RSSI component and read the DebUG log, u should see he other esp home device, not entirely sure if this is the way but I watch a good YouTube video where the guy reads sensors from Bluetooth logs and then assigns hem in HA. See intermit.tech channel on YT https://youtu.be/RtJpx8BZvMw

thinking this could be one way to transmit and communicate with the nodes solely

I am working ;his as I would like my wemos d1 to act as a wireless light switch using a battery and deep sleep so that when pushed will tall directly to the other esp and negate ANY need for a server such as HA or other device to also be online ,

Just some thoughts

The solution is here.

HTTP Request via EspHome web server

6 Likes

As this is #1 google result for such cases, I’m leaving a direct link to this solution here:

Light

web_server:
  port: 80

  
output:
  - platform: gpio
    pin: GPIO12
    id: relay_1

light:
  - platform: binary
    name: "default"
    id: light_1
    output: relay_1

status_led:
  pin:
    number: GPIO13
    inverted: yes

“Remote”

web_server:
  port: 80
  
http_request:
  useragent: esphome/device
  timeout: 10s
  

    
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: true
    name: "Sonoff Basic Button"
    on_press:
      - http_request.post: "http://192.168.0.50/light/default/toggle"
8 Likes

Just chiming in for the sake of teaching folks to fish.

You can use Chrome/Firefox developer tools to sniff the requests when toggling switches from an ESPHome device’s web interface.

I was able to figure out more complicated endpoints using this method.

Of course, this only occurred to me after reading @keex ‘s great reply, which is why I’m here. :slight_smile:

1 Like

ESP devices have a p2p communication channel called ESP-NOW. This allows blazing fast communication between ESP nodes without the need to initialize Wifi. This saves battery life and prolongs the life of battery powered devices.

Unfortunately this is not yet incorporated into ESPHome. There are discussions around it here and I found some documentation on a new component named ‘Wifi Now’ here but this seems to be a preview branch. Looks like we will have to wait some more time for it to be incorporated into the release version.

2 Likes

Hi, using this approach, it would be possible to send data from an esphome node to another? For example a temperature, voltage, power etc.

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