Added check for sensor before registering as a listener.