A group of adventurers enters a dimly lit room. Suddenly monsters lurking in the semi-darkness attack. How do I find out whether the players are surprised?
Dim light in 5E creates a "lightly obscured" area. Lightly obscured areas give you disadvantage on Wisdom (Perception) checks. But if players are not actively searching, they don't do Wisdom (Perception) checks, but rely on their passive perception. If attacked it is Dexterity (Stealth) of the attacker vs. passive Perception of the defender that determines surprise.
So how does dim light play into this? Would you use the same passive Perception to determine surprise and the dim light has no effect? Or do exceptionally the players have to make a active Perception roll, with disadvantage? What about characters with darkvision, who see in dim light as if it was bright light?