Trigger duration

I have a nodeMCU attached to a microswitch on my letter box lid that sends me a notification when I get mail. It’s worked fine for years when it was connected through Blynk, but since putting ESPHome on it and integrating it into HA, it’s become hyper sensitive and now triggers every time the front door is closed. In the automation, I set the duration to 1 sec which has removed the false triggers completely, but now I have the opposite problem - I don’t always get a notification as, if the postie is quick, the lid can be opened and closed within the second. Other parts of HA allow time measurements in smaller increments (delay can be 100ths of a second) so is there any way of setting a duration less than 1 sec? I feel 500ms would be long enough to prevent vibration triggering but short enough not to be defeated by a speedy postie.

I hadn’t noticed the “edit in YAML” option for the autmation, so I’ve gone into that and altered that to 0.5s and I’ll test it tomorrow.

Just about to tell you to do that.

trigger:
  - platform: state
    entity_id: binary_sensor.letter_box
    from: "off"
    to: "on"
    for:
      seconds: 0.5
1 Like

For completeness, the magic number turned out to be 0.35 secs. Yes it was that granular, 0.3 secs was still causing false triggers and 0.4 secs missed 1 delivery.