How to prevent action firing multiple times for one button press (not hardware debouncing I don't think!)

Following the good advice here, I’ve made good progress today with my project. First I did this

  - platform: gpio
    pin:
      number: 39
      mode: INPUT_PULLUP
      inverted: True
    name: "Buzzer"
    #filters:
    #  - delayed_on: 5ms
    on_press:
      if:
        condition:
          - script.is_running: alert_pathway
        then:
          - switch.turn_on: buzzer
          - delay: 50ms
          - switch.turn_off: buzzer
        else:
          - mqtt.publish:
              topic: warehouse/callpad
              payload: "CALM"
          - script.execute: alert_pathway
    on_release:
      then:
        - switch.turn_off: buzzer

which worked very well. Then I tried to get fancy with

  - platform: gpio
    pin:
      number: 39
      mode: INPUT_PULLUP
      inverted: True
    name: "Buzzer"
    #filters:
    #  - delayed_on: 5ms
    on_multi_click:
    - timing:
        - ON for at most 1s
        - OFF for at most 1s
        - ON for at most 1s
        - OFF for at least 0.2s
      then:
        - mqtt.publish:
            topic: warehouse/callpad
            payload: "pallet"
    - timing:
        - ON for 1s to 2s
        - OFF for at least 0.5s
      then:
        - mqtt.publish:
            topic: warehouse/callpad
            payload: "truck"
    - timing:
        - ON for at most 1s
        - OFF for at least 0.5s
      then:
        if:
          condition:
            - script.is_running: alert_pathway
          then:
            - switch.turn_on: buzzer
            - delay: 1s
            - switch.turn_off: buzzer
          else:
            - mqtt.publish:
                topic: warehouse/callpad
                payload: "calm"
            - script.execute: alert_pathway
    on_release:
      then:
        - switch.turn_off: buzzer

however this has the unintended side effect of sort of scatter-bombing the MQTT publishes. Depending on what button press type is used (and whether or not the script is running or not!), I’ll either get multiple pallets or multiple trucks, or both of those multiple times…
Somehow it seems this approach isn’t very clear between the different choices??

thank you!!

Try adding 20ms delayed_on and delayed_off filters to see if it is a switch debouncing issue.