How to set contact state from the contact sensor which detected a vibration

That makes sense. So back to variables, context variables, actually.

Take a look at this post where @josh describes their use.