Multiple EspHome communcation

Hello

I have a problem and I can’t find a solution anywhere. I have two EspHome devices which open my shutters like this:

switch:
- platform: gpio
  pin: GPIO23
  id: on_cover_1
- platform: gpio
  pin: GPIO22
  id: dir_cover_1

cover:
- platform: time_based
  name: "Tapparella 1"
  id: my_cover_1
  open_action:
    - switch.turn_on: on_cover_1
  open_duration: 24s
  close_action:
    - switch.turn_on: on_cover_1
    - switch.turn_on: dir_cover_1
  close_duration: 22s
  stop_action:
    - switch.turn_off: on_cover_1
    - switch.turn_off: dir_cover_1

That works great with HA. But now I would like to have another EspHome device that can open and close my shutters or light.
Is it possible to call a second EspHome directly or through HA?

Second ESPHome device

platform: gpio
  pin:
    number: GPIO35  # ---
    mode: INPUT_PULLUP
    inverted: true
  filters:
    - delayed_on: 50ms
    - delayed_off: 50ms
  id: button_close_1
  on_press:
    then:
      # logic for cycling through movements: open->stop->close->stop->...
      - lambda: |
          if (id(my_cover_1).current_operation == COVER_OPERATION_IDLE)  
            {
               id(my_cover_1).close();
            } 
          else 
            {
               id(my_cover_1).stop();   // Cover is opening/closing. Stop it
            }    


Let say id("esp2.local.my_cover_1").close();...

Thanks for your help!

Isn’t on_cover_1 a switch that you can access in HA?

I believe you can import the switch in the second esp as a binary sensor.

Or perhaps the sensor can’t be switched?

But if you add a gpio switch on the second esp and group the two entities in HA, then they should mirror each other.
Not a clean solution but it should work.

No, I don’t think that is possible with Binary sensor. You can also make an example for a simple light switch (no need for cover). So on one ESP I have gpio relay and on another ESP switch.

How can you make a group with two entities?

You can use services. See Native API Component — ESPHome

Thanks that works. You just create service in HA.

Then you need to add in EspHome

on_press:
  - homeassistant.service:
      service: script.luc