Modal window controlled by item value (open, close)

Hi,
I’m looking for a code of a modal window that would be triggered by a Switch item that keeps information of motion detected near front door. The triggered modal window would show stream from the front door camera, and after some defined amount of time, or based on triggered Switch item state, the modal window would be closed automatically. Does anybody have an example of such functionality and would mind to share a code?