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

There’s not currently a way to dynamically select a source device based on a variable or other dynamic information.

The closest feature requests are probably the following if you want to cast a vote:

I was originally thinking you could query the SmartThings API directly using an HTTP Action and the triggering device ID to get the state of a different attribute from the triggering device, but it looks like we don’t currently expose the device ID in the event context. If that’s a workaround you think you would be interested in, I would be happy to expose that additional property.