How to remember and show custom switch status

Hello everyone,

I have DR55B01 module that run my sprinkler system. This module connected into my ESP32 and using a simple switch that act like a simple push button operate the system (one click open the sprinkler another click close the sprinkler)

  - platform: gpio
    pin: 19
    id: sprinkler
    name: "sprinkler"
    icon: "mdi:sprinkler"
    - delay: 1000ms
    - switch.turn_off: sprinkler

How to remember and show the state of the system open or close on every click?

Add a template switch and a binary sensor