Click count

Hi!! I have a button on pin 8. How I can count of click? I want count on esp32 and load info in home assistant.

I try it. But pulse counter count pulse per minute. I want all time total.

Global variables helped me

globals:
  - id: totalClick
    type: float
    restore_value: yes
    initial_value: '18'

  - platform: pulse_counter
    pin: 
      number: 35
      mode: INPUT_PULLUP
    id: cold_water_sensor
    update_interval: 60s
    accuracy_decimals: 0

  - platform: template
    name: "Cold water total"
    unit_of_measurement: 'm3'
    accuracy_decimals: 2
    icon: "mdi:water"
    lambda: |-
      if (id(cold_water_sensor).state > 0) {
        id(totalClick) += id(cold_water_sensor).state;
      }
      return id(totalClick);

Does integration sensor not work?

I try use integration sensor. It’s really work. But restore value not work. I don’t know why