ESPHome settle: pass parameter

I’ve built a small ESP8266 pcb which lets me read the status of my wired home burglar alarm and lets me use the PIRs as home assistant presence sensors. The software was written using esphome and includes code that lets me count the number of times that each sensor has triggered which lets me build up a usage profile for each room. The end goal is to optimise the heating system based on room usage.
Some of the sensors trigger multiple times for a single PIR trigger event and to help getting false counts I’ve added a settle filter for each input (can have up to 16).

When I use the format

Zone switch if over threshold and increment count

binary_sensor:

  • platform: template
    name: “Side Hall trigger”
    lambda: ‘return id(adc_0).state < id(threshold).state;’
    filters:
    settle: 5s
    on_press:
    • lambda: ‘id(zone_1_count) += 1;’

the code builds OK.

I’d like to be able to adjust the delay without having to re-compile. I’ve added an input into the YAML

number:

  • platform: template
    name: “Settle Delay”
    id: settleDelay
    min_value: 0
    max_value: 6000
    step: 1
    initial_value: 3
    optimistic: true
    unit_of_measurement: “s”

however when I try to reference it in the settle statement I keep getting compiler errors. I’ve tried multiple options but none seem to work. Any suggestions?

Feel free to post the code you tried and the compiler error it gives.
And use code tags for both, so it’s readable.