Template Binary Sensor based on Button Press with 15s delay off (example)

I was having a difficult time making a template binary sensor that turned on when a button was pressed and remained on for 15s. I’m going to leave this here so someone might benefit from my work.

This format works (In config.yaml):

template:
  - triggers:
      - trigger: state
        entity_id: button.example
    binary_sensor:
      - name: "Button 15s Timeout"
        unique_id: button_15s_timeout
        state: "on"
        auto_off:
          seconds: 15
1 Like