Added API for setting the switch state