Check the demo here:
The block is 2 people as default.
Go OUT this block will decrease counts, IN will increase counts.
I plan to switch light OFF when counts goes 0, turn ON when counts goes 1 from 0.
The reference code is here: Note that the detection parameters need to be modified according to sensor setup.