Combine a switch and a sensor

Great but please learn to format your posts correctly. See point 11 here: How to help us help you - or How to ask a good question