Added function to check if a light is swiched off before setting the light