Wait_for_trigger

hi all,

I want to create automation using wait_for_trigger.
when my doorsensor open close two times( state on, off, on, off ) then my light turn off.

In a certain time frame?
So do you need to count the door cycles and on every even count do something?

@GlennHA certain time mean consecutive two times.
Like i open door and close then open again and close.
Actually, i want to apply on washroom doorsensor and light.

Ok…
Assume washroom door is usually in a closed state
Someone opens door
Enters
Relieves themselves and hopefully washes their hands
Opens door to leave
Exits

So you have a door sensor and a controllable light.
You could go simple.
Turn the light on every-time the door sensor is not made and turn off the light after x minutes after sensor is made. That way it doesn’t matter if someone opens the door, decides they don’t want to go in, then shuts it, and next person opens the door and the light will go off (not useful for them unless they can see in the dark).

example, not exactly the same idea but close. Instead of turning off a light I send a notification if the deep freezer door is open (which has an aeotec window/door sensor).

- id: '1601602101881'
  alias: Deep Freezer Door Notification
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.deep_freezer_door
    to: 'on'
    for: 0:05:00
  condition: []
  action:
  - service: notify.mobile_app_gphone
    data:
      message: Deep Freezer door is open
  - service: notify.mobile_app_sm_g950u
    data:
      message: Deep Freezer door is open
  mode: single

Actually i want for something.
Suppose, if some entity triggers ( 2 or 3 ) times within 10 seconds, then another entity turn on.

When one action or trigger performs for number of times then do this.