Smart sensor with inbuilt relay