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)

switch:
  - platform: gpio
    pin: 19
    id: sprinkler
    name: "sprinkler"
    icon: "mdi:sprinkler"
    on_turn_on:
    - 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