ESPHomeDevice1 to ESPHomeDevice2?

Hi there,

can someone tell me, is it possible to send commands like turnon a switch from, a ESPHome Device1 to ESPHome Device2 WITHOUT using HA?

If so, how can i do that?

Hello,

You can use MQTT messages.

The on_message fonction can be use to listen message from other device

no other way without MQTT?

Yes, I do this with a wall switch that, in addition to controlling its AC outlet also sends commands to a pair of plug-in dimmers (all running ESPHome), so they all act as one under the control of the wall switch.
I do it using ESPHome’s http_request component, calling the native API of the remote modules.
A ‘script’ component holds the code, and can be called from any of the automation triggers.
Here’s a sample of the script.

  - id: send_change_to_slave
    then:
      - http_request.get:
          verify_ssl: false
          url: !lambda |-
            char urlstring[96];
            char host[] = "hostname-of-remote-unit";
            if( id(light_dimmer).current_values.is_on() ) {
              sprintf( (urlstring), "http://%s/light/0?turn=on&brightness=%u", host,
                  max( 1, int( 100.0 * id(light_dimmer).current_values.get_brightness() ) )
                  );
            } else {
              sprintf( (urlstring), "http://%s/light/0?turn=off", host );
            }
            return (urlstring);

HTH

1 Like

Took me a long time to find this in the docs, but once I did, the above became easy.
https://esphome.io/web-api/index.html