5V Relay and ESPHome

It is not necessary to use an LED.
Try using this code

switch:
  - platform: gpio
    name: "Rele1"
    pin: 
      number: D5
      inverted: true
      mode: 
        output: True
        open_drain: True
    restore_mode: ALWAYS_OFF
8 Likes