handle pin_state events