Send toggle state on wake up from deep sleep mode esp32, how to do it?

Hi :slight_smile:

I´m new to code in esphome, I have got my esp32s up and running and use deep sleep mode, but now I will have it to automatic after it wakes up from deep sleep mode to send toggle state to binary sensor.

Hope your understand what I´m need help to.
Best Regards Stig

my code is here :

esphome:
  name: mqttbutton1
  platform: ESP32
  board: nodemcu-32s

wifi:
  ssid: "xxxxxx"
  password: "xxxxxx"
  manual_ip:
    # Set this to the IP of the ESP
    static_ip: 192.168.1.75
    # Set this to the IP address of the router. Often ends with .1
    gateway: 192.168.1.1
    # The subnet of the network. 255.255.255.0 works for most home networks.
    subnet: 255.255.255.0
binary_sensor:
  
  - platform: gpio
    name: "25mqttbutton2"
    pin: 
     number: 25
     inverted: False
     mode: INPUT_PULLDOWN
    device_class: 'opening'
    filters:     
      - delayed_off: 1000ms 

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "xxxxxx"

ota:
  password: "xxxxxx"
  
deep_sleep:
    run_duration: 40s
    sleep_duration: 10min
    wakeup_pin: GPIO25
    id: deep_sleep_1


As waking from deep sleep reboots the device you can use the on_boot event:

However you can not toggle a binary sensor. Sensors read states, theyt are not controllable. You would need an output or switch.