Component control pattern matching

Not sure if this is possible, but would be awesome if it was. I was looking at this http://knocki.com, and thought that I should be able to replicate it with a vibration sensor and setting a automation that is triggered when it receives the vibration signal.
If you watch the video though, it appears that you will be able to create custom “knock” patterns that can trigger different actions. This got me thinking, is this currently possible with HA automations? For example, if HA were to receive a single vibration signal it would trigger a single light.turn_on action, or if it received two vibration signals in succession it would trigger a light.turn_off action.
This could be especially useful for in wall smart switches, an example would be tap once to toggle the bathroom light, tap and hold to toggle the bathroom fan, tap the entry light 4 times to turn off all lights in the house, etc.
Is this kind of thing currently possible?

With only the config.yaml I think it is possible but just not feasable to do so. Maybe if you would use AppDeamon.

~Cheers

You could send intents based on the patterns detected.

Well, Knocki is out and shipping. they have a cloud service for integrations. Basically it could be used as a trigger for any automation.