try this. it helped me a lot when I first started. You need to add the custom device handler for the switch.