How to triggering automation after the third opening of the door?

Hey guys, I’m the first day with the Home Assistant, help me please, how to make the trigger for automations on the third opening with the door sensor? That is, so that the action is triggered only after the third opening, from the moment this automation is enabled.

I tried to add three such triggers (Trigger type - Device), but it didn’t work. It was triggering after each opening((

type: opened
platform: device
device_id: XXX
entity_id: binary_sensor.***_contact
domain: binary_sensor

Add a counter helper.
Add an automation to add one to the counter each time the door opens.
Add an automation to reset the counter to zero when the other automation is enabled (the one below).
And lastly add an automation to trigger when the counter is 3.


Yes, thanks so much, it works)